diff --git a/apps/desktop/src/Router.tsx b/apps/desktop/src/Router.tsx index 7263fa423..3cab2d393 100644 --- a/apps/desktop/src/Router.tsx +++ b/apps/desktop/src/Router.tsx @@ -94,46 +94,33 @@ const LoggedOutRouter = () => { return; } - persistor.pause(); const getBackupData = async () => { + persistor.pause() + const backupData = await window.electronAPI.getBackupData(); if (!backupData) { setIsDataLoading(false); localStorage.setItem("migration_2_3_3_to_2_3_4_completed", "true"); + persistor.persist() return; } + + await persistor.flush() localStorage.clear(); localStorage.setItem("migration_2_3_3_to_2_3_4_completed", "true"); localStorage.setItem("persist:accounts", JSON.stringify(backupData["persist:accounts"])); localStorage.setItem("persist:root", JSON.stringify(backupData["persist:root"])); + persistor.persist() + window.location.reload(); }; - getBackupData(); - - // if (window.electronAPI) { - // window.electronAPI.onBackupData((_, data) => { - // if (data) { - // setTimeout(() => { - // localStorage.clear(); - - // localStorage.setItem("migration_2_3_3_to_2_3_4_completed", "true"); - // localStorage.setItem("persist:accounts", JSON.stringify(data["persist:accounts"])); - // localStorage.setItem("persist:root", JSON.stringify(data["persist:root"])); - - // window.location.reload(); - // }, 3000); - // } else { - // setIsDataLoading(false); - // localStorage.setItem("migration_2_3_3_to_2_3_4_completed", "true"); - // } - // }); - // } + getBackupData().catch(() => {}); }, []); return (