diff --git a/web/redux/persist.js b/web/redux/persist.js --- a/web/redux/persist.js +++ b/web/redux/persist.js @@ -54,27 +54,6 @@ }; }, [2]: async state => { - const databaseModule = await getDatabaseModule(); - const isDatabaseSupported = await databaseModule.isDatabaseSupported(); - if (!isDatabaseSupported) { - return state; - } - - const { drafts } = state.draftStore; - const draftStoreOperations = []; - for (const key in drafts) { - const text = drafts[key]; - draftStoreOperations.push({ - type: 'update', - payload: { key, text }, - }); - } - - await databaseModule.schedule({ - type: workerRequestMessageTypes.PROCESS_STORE_OPERATIONS, - storeOperations: { draftStoreOperations }, - }); - return state; }, [3]: async (state: AppState) => { @@ -125,6 +104,34 @@ }, }; }, + [5]: async state => { + const databaseModule = await getDatabaseModule(); + const isDatabaseSupported = await databaseModule.isDatabaseSupported(); + if (!isDatabaseSupported) { + return state; + } + + if (!state.draftStore) { + return state; + } + + const { drafts } = state.draftStore; + const draftStoreOperations = []; + for (const key in drafts) { + const text = drafts[key]; + draftStoreOperations.push({ + type: 'update', + payload: { key, text }, + }); + } + + await databaseModule.schedule({ + type: workerRequestMessageTypes.PROCESS_STORE_OPERATIONS, + storeOperations: { draftStoreOperations }, + }); + + return state; + }, }; const persistWhitelist = [ @@ -234,7 +241,7 @@ { debug: isDev }, migrateStorageToSQLite, ): any), - version: 4, + version: 5, transforms: [keyserverStoreTransform], };