From fe42a3c2ed8c8871831e8960b32e1546ecba623c Mon Sep 17 00:00:00 2001 From: Tom Hacohen Date: Sat, 22 Feb 2020 15:47:38 +0200 Subject: [PATCH] Add migrations for the changes in the store's structure --- src/store/construct.ts | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/store/construct.ts b/src/store/construct.ts index d113c12..96bb14a 100644 --- a/src/store/construct.ts +++ b/src/store/construct.ts @@ -30,10 +30,18 @@ const settingsPersistConfig = { storage: localforage, }; +const credentialsMigrations = { + 0: (state: any) => { + return state.value; + }, +}; + const credentialsPersistConfig = { key: 'credentials', + version: 0, storage: localforage, whitelist: ['value'], + migrate: createMigrate(credentialsMigrations, { debug: false }), }; const encryptionKeyPersistConfig = { @@ -141,11 +149,19 @@ const cacheMigrations = { journals: undefined, }; }, + 2: (state: any) => { + return { + ...state, + userInfo: state.userInfo?.value, + journals: state.journals?.value, + entries: undefined, // For now we just reset the entries + }; + }, }; const cachePersistConfig = { key: 'cache', - version: 1, + version: 2, storage: localforage, transforms: [createTransform(cacheSerialize, cacheDeserialize)], migrate: createMigrate(cacheMigrations, { debug: false }),