From f8b20ff7d71c7d3f33f9b34812c97b6ac5ab8d2c Mon Sep 17 00:00:00 2001 From: Oleg Chendighelean Date: Wed, 18 Dec 2024 11:23:27 +0000 Subject: [PATCH] Add flag to check if migration is completed --- apps/desktop/public/electron.js | 1 - packages/state/src/reducer.ts | 7 +++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/apps/desktop/public/electron.js b/apps/desktop/public/electron.js index 0a8cf0cb2..0e73c7cc3 100644 --- a/apps/desktop/public/electron.js +++ b/apps/desktop/public/electron.js @@ -69,7 +69,6 @@ async function createBackupFromPrevDB() { "beacon", "networks", "contacts", - "errors", "protocolSettings", "_persist", ]; diff --git a/packages/state/src/reducer.ts b/packages/state/src/reducer.ts index b10027a67..f7179b51e 100644 --- a/packages/state/src/reducer.ts +++ b/packages/state/src/reducer.ts @@ -76,11 +76,13 @@ 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) => { @@ -88,6 +90,7 @@ export const makeReducer = (storage_: Storage | undefined) => { const processed = processMigrationData(data); if (processed) { + localStorage.setItem(MIGRATION_KEY, "true"); return resolve(processed[config.key as keyof typeof processed]); } }