mirror of
https://github.com/ChatGPTNextWeb/ChatGPT-Next-Web.git
synced 2025-10-01 15:46:39 +08:00
wait for store hydration
This commit is contained in:
parent
7869f7cc5f
commit
02ce9681ff
@ -154,10 +154,18 @@ export function WindowContent(props: { children: React.ReactNode }) {
|
||||
|
||||
function useSyncOnStart() {
|
||||
const syncStore = useSyncStore();
|
||||
const storeHasHydrated = useSyncStore((s) => s._hasHydrated);
|
||||
useEffect(() => {
|
||||
let running = true;
|
||||
setTimeout(async () => {
|
||||
if (!(running && syncStore.cloudSync() && syncStore.autoSync.onStart)) {
|
||||
if (
|
||||
!(
|
||||
storeHasHydrated &&
|
||||
running &&
|
||||
syncStore.cloudSync() &&
|
||||
syncStore.autoSync.onStart
|
||||
)
|
||||
) {
|
||||
return;
|
||||
}
|
||||
const dismissSyncingToast = showToast(Locale.Settings.Sync.IsSyncing);
|
||||
@ -175,7 +183,7 @@ function useSyncOnStart() {
|
||||
running = false;
|
||||
};
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, []);
|
||||
}, [storeHasHydrated]);
|
||||
}
|
||||
|
||||
function Screen() {
|
||||
|
Loading…
Reference in New Issue
Block a user