diff --git a/web/root.js b/web/root.js --- a/web/root.js +++ b/web/root.js @@ -26,6 +26,11 @@ import Socket from './socket.react.js'; import { workerRequestMessageTypes } from './types/worker-types.js'; +const initiallyLoggedInUserID = preloadedState.currentUserInfo?.anonymous + ? undefined + : preloadedState.currentUserInfo?.id; +const isDatabaseSupported = isSQLiteSupported(initiallyLoggedInUserID); + const migrations = { [1]: async state => { const { @@ -43,11 +48,7 @@ }; }, [2]: async state => { - const currentLoggedInUserID = preloadedState.currentUserInfo?.anonymous - ? undefined - : preloadedState.currentUserInfo?.id; - const isSupported = isSQLiteSupported(currentLoggedInUserID); - if (!isSupported) { + if (!isDatabaseSupported) { return state; } @@ -69,17 +70,20 @@ return state; }, }; +const persistWhitelist = [ + 'enabledApps', + 'deviceID', + 'cryptoStore', + 'notifPermissionAlertInfo', + 'commServicesAccessToken', +]; + const persistConfig = { key: 'root', storage, - whitelist: [ - 'enabledApps', - 'deviceID', - 'draftStore', - 'cryptoStore', - 'notifPermissionAlertInfo', - 'commServicesAccessToken', - ], + whitelist: isDatabaseSupported + ? persistWhitelist + : [...persistWhitelist, 'draftStore'], migrate: (createAsyncMigrate(migrations, { debug: isDev }): any), version: 2, };