mirror of
https://github.com/ChatGPTNextWeb/ChatGPT-Next-Web.git
synced 2025-10-01 23:56: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() {
|
function useSyncOnStart() {
|
||||||
const syncStore = useSyncStore();
|
const syncStore = useSyncStore();
|
||||||
|
const storeHasHydrated = useSyncStore((s) => s._hasHydrated);
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
let running = true;
|
let running = true;
|
||||||
setTimeout(async () => {
|
setTimeout(async () => {
|
||||||
if (!(running && syncStore.cloudSync() && syncStore.autoSync.onStart)) {
|
if (
|
||||||
|
!(
|
||||||
|
storeHasHydrated &&
|
||||||
|
running &&
|
||||||
|
syncStore.cloudSync() &&
|
||||||
|
syncStore.autoSync.onStart
|
||||||
|
)
|
||||||
|
) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const dismissSyncingToast = showToast(Locale.Settings.Sync.IsSyncing);
|
const dismissSyncingToast = showToast(Locale.Settings.Sync.IsSyncing);
|
||||||
@ -175,7 +183,7 @@ function useSyncOnStart() {
|
|||||||
running = false;
|
running = false;
|
||||||
};
|
};
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
}, []);
|
}, [storeHasHydrated]);
|
||||||
}
|
}
|
||||||
|
|
||||||
function Screen() {
|
function Screen() {
|
||||||
|
Loading…
Reference in New Issue
Block a user