Rename Credentials2/Cache2 (left-overs from the etebase migration).

master
Tom Hacohen 4 years ago
parent abf2224d31
commit 346dc95cee

@ -11,12 +11,12 @@ import {
SettingsType, SettingsType,
fetchCount, credentials, settingsReducer, encryptionKeyReducer, errorsReducer, fetchCount, credentials, settingsReducer, encryptionKeyReducer, errorsReducer,
syncGeneral, syncCollections, collections, items, syncGeneral, syncCollections, collections, items,
SyncGeneralData, SyncCollectionsData, CacheCollectionsData, CacheItemsData, CredentialsData2, SyncGeneralData, SyncCollectionsData, CacheCollectionsData, CacheItemsData, CredentialsData,
} from "./reducers"; } from "./reducers";
export interface StoreState { export interface StoreState {
fetchCount: number; fetchCount: number;
credentials2: CredentialsData2; credentials2: CredentialsData;
settings: SettingsType; settings: SettingsType;
encryptionKey: {key: string}; encryptionKey: {key: string};
sync: { sync: {
@ -49,7 +49,7 @@ const settingsPersistConfig = {
migrate: createMigrate(settingsMigrations, { debug: false }), migrate: createMigrate(settingsMigrations, { debug: false }),
}; };
const credentials2PersistConfig = { const credentialsPersistConfig = {
key: "credentials2", key: "credentials2",
version: 0, version: 0,
storage: localforage, storage: localforage,
@ -82,7 +82,7 @@ const syncPersistConfig = {
transforms: [createTransform(syncSerialize, syncDeserialize)], transforms: [createTransform(syncSerialize, syncDeserialize)],
}; };
const cache2Serialize = (state: any, key: string | number) => { const cacheSerialize = (state: any, key: string | number) => {
if (key === "collections") { if (key === "collections") {
return state.toJS(); return state.toJS();
} else if (key === "items") { } else if (key === "items") {
@ -92,7 +92,7 @@ const cache2Serialize = (state: any, key: string | number) => {
return state; return state;
}; };
const cache2Deserialize = (state: any, key: string | number) => { const cacheDeserialize = (state: any, key: string | number) => {
if (key === "collections") { if (key === "collections") {
return ImmutableMap(state); return ImmutableMap(state);
} else if (key === "items") { } else if (key === "items") {
@ -104,23 +104,23 @@ const cache2Deserialize = (state: any, key: string | number) => {
return state; return state;
}; };
const cache2PersistConfig = { const cachePersistConfig = {
key: "cache2", key: "cache2",
version: 0, version: 0,
storage: localforage, storage: localforage,
transforms: [createTransform(cache2Serialize, cache2Deserialize)] as any, transforms: [createTransform(cacheSerialize, cacheDeserialize)] as any,
}; };
const reducers = combineReducers({ const reducers = combineReducers({
fetchCount, fetchCount,
settings: persistReducer(settingsPersistConfig, settingsReducer), settings: persistReducer(settingsPersistConfig, settingsReducer),
credentials2: persistReducer(credentials2PersistConfig, credentials), credentials2: persistReducer(credentialsPersistConfig, credentials),
encryptionKey: persistReducer(encryptionKeyPersistConfig, encryptionKeyReducer), encryptionKey: persistReducer(encryptionKeyPersistConfig, encryptionKeyReducer),
sync: persistReducer(syncPersistConfig, combineReducers({ sync: persistReducer(syncPersistConfig, combineReducers({
collections: syncCollections, collections: syncCollections,
general: syncGeneral, general: syncGeneral,
})), })),
cache2: persistReducer(cache2PersistConfig, combineReducers({ cache2: persistReducer(cachePersistConfig, combineReducers({
collections, collections,
items, items,
})), })),

@ -30,14 +30,14 @@ export type SyncGeneralData = {
lastSyncDate: Date; lastSyncDate: Date;
}; };
export interface CredentialsData2 { export interface CredentialsData {
storedSession?: string; storedSession?: string;
} }
export const credentials = handleActions( export const credentials = handleActions(
{ {
[actions.login.toString()]: ( [actions.login.toString()]: (
state: CredentialsData2, action: Action<string>) => { state: CredentialsData, action: Action<string>) => {
if (action.error) { if (action.error) {
return state; return state;
} else if (action.payload === undefined) { } else if (action.payload === undefined) {
@ -48,7 +48,7 @@ export const credentials = handleActions(
}; };
} }
}, },
[actions.logout.toString()]: (_state: CredentialsData2, _action: any) => { [actions.logout.toString()]: (_state: CredentialsData, _action: any) => {
return { storedSession: undefined }; return { storedSession: undefined };
}, },
}, },

Loading…
Cancel
Save