Add migrations for the changes in the store's structure

master
Tom Hacohen 5 years ago
parent 6ed0f02abc
commit fe42a3c2ed

@ -30,10 +30,18 @@ const settingsPersistConfig = {
storage: localforage, storage: localforage,
}; };
const credentialsMigrations = {
0: (state: any) => {
return state.value;
},
};
const credentialsPersistConfig = { const credentialsPersistConfig = {
key: 'credentials', key: 'credentials',
version: 0,
storage: localforage, storage: localforage,
whitelist: ['value'], whitelist: ['value'],
migrate: createMigrate(credentialsMigrations, { debug: false }),
}; };
const encryptionKeyPersistConfig = { const encryptionKeyPersistConfig = {
@ -141,11 +149,19 @@ const cacheMigrations = {
journals: undefined, 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 = { const cachePersistConfig = {
key: 'cache', key: 'cache',
version: 1, version: 2,
storage: localforage, storage: localforage,
transforms: [createTransform(cacheSerialize, cacheDeserialize)], transforms: [createTransform(cacheSerialize, cacheDeserialize)],
migrate: createMigrate(cacheMigrations, { debug: false }), migrate: createMigrate(cacheMigrations, { debug: false }),

Loading…
Cancel
Save