Skip to content

Commit

Permalink
Add flag to check if migration is completed
Browse files Browse the repository at this point in the history
  • Loading branch information
OKendigelyan committed Dec 18, 2024
1 parent 3969823 commit dcb49eb
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
1 change: 0 additions & 1 deletion apps/desktop/public/electron.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ async function createBackupFromPrevDB() {
"beacon",
"networks",
"contacts",
"errors",
"protocolSettings",
"_persist",
];
Expand Down
7 changes: 5 additions & 2 deletions packages/state/src/reducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,18 +76,21 @@ export const makeReducer = (storage_: Storage | undefined) => {
try {
const state = (await getStoredState(config)) as PersistedState;

if (state) {
const MIGRATION_KEY = "migration_2_3_3_to_2_3_4_completed";
const isMigrationCompleted = localStorage.getItem(MIGRATION_KEY);

if (isMigrationCompleted && state) {
return state;
}

// If no state, check if we have backup data and migrate it to the new state
if (window.electronAPI) {
return new Promise(resolve => {
window.electronAPI?.onBackupData((_, data) => {
if (data) {
const processed = processMigrationData(data);

if (processed) {
localStorage.setItem(MIGRATION_KEY, "true");
return resolve(processed[config.key as keyof typeof processed]);
}
}
Expand Down

0 comments on commit dcb49eb

Please sign in to comment.