Skip to content

Commit

Permalink
Handle redux-persist init
Browse files Browse the repository at this point in the history
  • Loading branch information
OKendigelyan committed Dec 20, 2024
1 parent aea73b4 commit 2b25461
Showing 1 changed file with 8 additions and 21 deletions.
29 changes: 8 additions & 21 deletions apps/desktop/src/Router.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down

0 comments on commit 2b25461

Please sign in to comment.