fix: clean local async data

Signed-off-by: Innei <i@innei.in>
This commit is contained in:
Innei 2024-08-03 19:26:25 +08:00
parent 2c650b08ae
commit ae26dd7763
No known key found for this signature in database
GPG Key ID: 0F62D33977F021F7
3 changed files with 9 additions and 8 deletions

View File

@ -8,9 +8,6 @@ import { useCallback } from "react"
export const useSignOut = () =>
useCallback(async () => {
// clear local store data
clearLocalPersistStoreData()
// Clear query cache
localStorage.removeItem(QUERY_PERSIST_KEY)
@ -20,7 +17,11 @@ export const useSignOut = () =>
// Clear local storage
clearStorage()
window.posthog?.reset()
tipcClient?.cleanAuthSessionToken()
// clear local store data
await Promise.allSettled([
clearLocalPersistStoreData(),
tipcClient?.cleanAuthSessionToken(),
])
// Sign out
await signOut()
}, [])

View File

@ -103,8 +103,8 @@ export const SettingGeneral = () => {
},
{
label: "Rebuild Database",
action: () => {
clearLocalPersistStoreData()
action: async () => {
await clearLocalPersistStoreData()
window.location.reload()
},
description:

View File

@ -6,7 +6,7 @@ import { feedActions } from "../feed"
import { subscriptionActions } from "../subscription"
import { feedUnreadActions } from "../unread"
export const clearLocalPersistStoreData = () => {
export const clearLocalPersistStoreData = async () => {
// All clear and reset method will aggregate here
[entryActions, subscriptionActions, feedUnreadActions, feedActions].forEach(
(actions) => {
@ -16,5 +16,5 @@ export const clearLocalPersistStoreData = () => {
clearUISettings()
browserDB.delete()
await browserDB.delete().catch(() => null)
}