|
|
@ -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,
|
|
|
|
})),
|
|
|
|
})),
|
|
|
|