diff --git a/app/store/prompt.ts b/app/store/prompt.ts index 29a97abba5f..a25cda5813a 100644 --- a/app/store/prompt.ts +++ b/app/store/prompt.ts @@ -179,8 +179,6 @@ export const usePromptStore = createPersistStore( res.en.length + res.cn.length + res.tw.length; SearchService.init(allPromptsForSearch, userPrompts); }); - - return () => state.setHasHydrated(true); }, }, ); diff --git a/app/utils/indexedDB-storage.ts b/app/utils/indexedDB-storage.ts index 86b30477788..da309455013 100644 --- a/app/utils/indexedDB-storage.ts +++ b/app/utils/indexedDB-storage.ts @@ -15,6 +15,7 @@ class IndexedDBStorage implements StateStorage { try { const _value = JSON.parse(value); if (!_value?.state?._hasHydrated) { + console.warn("skip setItem", name); return; } await set(name, value); diff --git a/app/utils/store.ts b/app/utils/store.ts index 02c8139b0ad..ff15bee14ed 100644 --- a/app/utils/store.ts +++ b/app/utils/store.ts @@ -35,11 +35,12 @@ export function createPersistStore( persistOptions: SecondParam>>, ) { persistOptions.storage = createJSONStorage(() => indexedDBStorage); - persistOptions.onRehydrateStorage = persistOptions.onRehydrateStorage - ? persistOptions.onRehydrateStorage - : (state) => { - return () => state.setHasHydrated(true); - }; + const oldOonRehydrateStorage = persistOptions?.onRehydrateStorage; + persistOptions.onRehydrateStorage = (state) => { + oldOonRehydrateStorage?.(state); + return () => state.setHasHydrated(true); + }; + return create( persist( combine(