Skip to content

Commit

Permalink
Await async storage updates (#969)
Browse files Browse the repository at this point in the history
  • Loading branch information
sceuick authored Jul 7, 2024
1 parent 53e382c commit d435d3a
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion web/shared/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ export function getAssetUrl(filename: string) {
export function setAssetPrefix(prefix: string) {
if (!prefix && assetPrefix) return

storage.setItem(PREFIX_CACHE_KEY, prefix)
storage.localSetItem(PREFIX_CACHE_KEY, prefix)
assetPrefix = prefix
}

Expand Down
4 changes: 2 additions & 2 deletions web/store/character.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,9 +201,9 @@ export const characterStore = createStore<CharacterState>(
}
},

impersonate(_, char?: AppSchema.Character, chatId?: string) {
async impersonate(_, char?: AppSchema.Character, chatId?: string) {
if (!chatId) {
storage.setItem(IMPERSONATE_KEY, char?._id || '')
await storage.localSetItem(IMPERSONATE_KEY, char?._id || '')
} else {
setStoredValue(`${chatId}-impersonate`, char?._id || '')
}
Expand Down
4 changes: 2 additions & 2 deletions web/store/data/storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ export async function saveMessages(chatId: string, messages: AppSchema.ChatMessa
if (SELF_HOSTING) {
return api.post(`/json/messages/${chatId}`, messages)
} else {
storage.setItem(key, JSON.stringify(messages))
await storage.setItem(key, JSON.stringify(messages))
}
}

Expand Down Expand Up @@ -334,7 +334,7 @@ export async function loadItem<TKey extends keyof typeof KEYS>(
}

const fallback = fallbacks[key]
storage.setItem(key, JSON.stringify(fallback))
await storage.setItem(key, JSON.stringify(fallback))

return fallback
}
Expand Down

0 comments on commit d435d3a

Please sign in to comment.