fix: clean local async data
Signed-off-by: Innei <i@innei.in>
This commit is contained in:
parent
2c650b08ae
commit
ae26dd7763
|
|
@ -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()
|
||||
}, [])
|
||||
|
|
|
|||
|
|
@ -103,8 +103,8 @@ export const SettingGeneral = () => {
|
|||
},
|
||||
{
|
||||
label: "Rebuild Database",
|
||||
action: () => {
|
||||
clearLocalPersistStoreData()
|
||||
action: async () => {
|
||||
await clearLocalPersistStoreData()
|
||||
window.location.reload()
|
||||
},
|
||||
description:
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue