Make storage async
This commit is contained in:
@@ -58,8 +58,8 @@ export class ChatService {
|
||||
}
|
||||
}
|
||||
|
||||
getQuick(): Message[] {
|
||||
const chats = this.database.get("chats", this.userid)
|
||||
async getQuick(): Promise<Message[]> {
|
||||
const chats = await this.database.get("chats", this.userid)
|
||||
if (chats) {
|
||||
return JSON.parse(chats)
|
||||
} else {
|
||||
|
||||
@@ -65,8 +65,8 @@ export class DMService {
|
||||
}
|
||||
}
|
||||
|
||||
getQuick(): Message[] {
|
||||
const messages = this.database.get("messages", this.chatid)
|
||||
async getQuick(): Promise<Message[]> {
|
||||
const messages = await this.database.get("messages", this.chatid)
|
||||
if (messages) {
|
||||
return JSON.parse(messages)
|
||||
} else {
|
||||
|
||||
@@ -108,8 +108,8 @@ export class NetworkService {
|
||||
}
|
||||
}
|
||||
|
||||
getQuick(): Message[] {
|
||||
const networks = this.database.get("networks", this.userid)
|
||||
async getQuick(): Promise<Message[]> {
|
||||
const networks = await this.database.get("networks", this.userid)
|
||||
if (networks) {
|
||||
return JSON.parse(networks)
|
||||
} else {
|
||||
|
||||
@@ -54,8 +54,8 @@ export class PictureService {
|
||||
}
|
||||
}
|
||||
|
||||
getQuick(): Message[] {
|
||||
const pictures = this.database.get("pictures", this.uploaderId)
|
||||
async getQuick(): Promise<Message[]> {
|
||||
const pictures = await this.database.get("pictures", this.uploaderId)
|
||||
if (pictures) {
|
||||
return JSON.parse(pictures)
|
||||
} else {
|
||||
|
||||
@@ -33,18 +33,18 @@ export class SessionManager {
|
||||
/**
|
||||
* Loads all saved sessions
|
||||
*/
|
||||
loadSessions(): Session[] {
|
||||
const tokens = this.keyring.getAll()
|
||||
async loadSessions(): Promise<Session[]> {
|
||||
const tokens = await this.keyring.getAll()
|
||||
const sessions: Session[] = []
|
||||
tokens.forEach(token => {
|
||||
const userData = this.database.get("sessions", token.split(".")[0])
|
||||
for (const token of tokens) {
|
||||
const userData = await this.database.get("sessions", token.split(".")[0])
|
||||
if (userData) {
|
||||
sessions.push({
|
||||
token: token,
|
||||
userData: JSON.parse(userData)
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
return sessions
|
||||
}
|
||||
@@ -52,8 +52,8 @@ export class SessionManager {
|
||||
/**
|
||||
* Gets the preferred user set by the client
|
||||
*/
|
||||
getPreferredUser(): string {
|
||||
return this.KeyValue.get("preferredUser") ?? ""
|
||||
async getPreferredUser(): Promise<string> {
|
||||
return await this.KeyValue.get("preferredUser") ?? ""
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -67,9 +67,9 @@ export class SessionManager {
|
||||
/**
|
||||
* Loads the preferred session by the client
|
||||
*/
|
||||
loadPreferredSession() {
|
||||
const sessions = this.loadSessions()
|
||||
let preferredUser = this.getPreferredUser()
|
||||
async loadPreferredSession() {
|
||||
const sessions = await this.loadSessions()
|
||||
let preferredUser = await this.getPreferredUser()
|
||||
if (preferredUser == "") {
|
||||
preferredUser = sessions[0].userData.userid
|
||||
this.setPreferredUser(sessions[0].userData.userid)
|
||||
|
||||
@@ -71,8 +71,8 @@ export class TextChannelServiceService {
|
||||
}
|
||||
}
|
||||
|
||||
getQuick(): Message[] {
|
||||
const messages = this.database.get("networkmessages", this.channelId)
|
||||
async getQuick(): Promise<Message[]> {
|
||||
const messages = await this.database.get("networkmessages", this.channelId)
|
||||
if (messages) {
|
||||
return JSON.parse(messages)
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user