Skip to content

Commit

Permalink
wait for store hydration
Browse files Browse the repository at this point in the history
  • Loading branch information
jokester committed Oct 22, 2024
1 parent 7869f7c commit 02ce968
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions app/components/home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -175,7 +183,7 @@ function useSyncOnStart() {
running = false;
};
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
}, [storeHasHydrated]);
}

function Screen() {
Expand Down

0 comments on commit 02ce968

Please sign in to comment.