From e58f3dd9e6daaa1ad1dd1e6c8805e2cad559c689 Mon Sep 17 00:00:00 2001 From: Tom Hacohen Date: Sat, 8 Aug 2020 12:10:23 +0300 Subject: [PATCH] Rename cache/credentials2 to remove the 2. As long as we keep the cache key the same, it's fine to change the user facing parts. --- src/Debug.tsx | 4 ++-- src/credentials.tsx | 2 +- src/etebase-helpers.ts | 6 +++--- src/store/construct.ts | 8 ++++---- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/Debug.tsx b/src/Debug.tsx index dc5e036..be3dfb6 100644 --- a/src/Debug.tsx +++ b/src/Debug.tsx @@ -17,8 +17,8 @@ export default function Debug() { const [stateCollectionUid, setCollectionUid] = React.useState(""); const [itemsUids, setEntriesUids] = React.useState(""); const [result, setResult] = React.useState(""); - const cacheCollections = useSelector((state: StoreState) => state.cache2.collections); - const cacheItems = useSelector((state: StoreState) => state.cache2.items); + const cacheCollections = useSelector((state: StoreState) => state.cache.collections); + const cacheItems = useSelector((state: StoreState) => state.cache.items); function handleInputChange(func: (value: string) => void) { return (event: React.ChangeEvent) => { diff --git a/src/credentials.tsx b/src/credentials.tsx index bf8c1bd..a80ddfc 100644 --- a/src/credentials.tsx +++ b/src/credentials.tsx @@ -10,7 +10,7 @@ import * as store from "./store"; import { usePromiseMemo } from "./helpers"; export const credentialsSelector = createSelector( - (state: store.StoreState) => state.credentials2.storedSession, + (state: store.StoreState) => state.credentials.storedSession, (storedSession) => { if (storedSession) { return Etebase.Account.restore(storedSession); diff --git a/src/etebase-helpers.ts b/src/etebase-helpers.ts index b65bd6e..e9fd80a 100644 --- a/src/etebase-helpers.ts +++ b/src/etebase-helpers.ts @@ -58,7 +58,7 @@ export const getCollectionManager = memoize(function (etebase: Etebase.Account) // React specific stuff export function useCollections(etebase: Etebase.Account, colType?: string) { - const cachedCollections = useSelector((state: StoreState) => state.cache2.collections); + const cachedCollections = useSelector((state: StoreState) => state.cache.collections); return usePromiseMemo( (colType) ? getCollectionsByType(cachedCollections, colType, etebase) : @@ -68,8 +68,8 @@ export function useCollections(etebase: Etebase.Account, colType?: string) { } export function useItems(etebase: Etebase.Account, colType: string) { - const cachedCollections = useSelector((state: StoreState) => state.cache2.collections); - const cachedItems = useSelector((state: StoreState) => state.cache2.items); + const cachedCollections = useSelector((state: StoreState) => state.cache.collections); + const cachedItems = useSelector((state: StoreState) => state.cache.items); return usePromiseMemo( getItemsByType(cachedCollections, cachedItems, colType, etebase), [etebase, cachedCollections, cachedItems, colType] diff --git a/src/store/construct.ts b/src/store/construct.ts index 99af128..e1f830e 100644 --- a/src/store/construct.ts +++ b/src/store/construct.ts @@ -18,14 +18,14 @@ import { export interface StoreState { fetchCount: number; - credentials2: CredentialsData; + credentials: CredentialsData; settings: SettingsType; encryptionKey: {key: string}; sync: { collections: SyncCollectionsData; general: SyncGeneralData; }; - cache2: { + cache: { collections: CacheCollectionsData; items: CacheItemsData; }; @@ -124,13 +124,13 @@ const cachePersistConfig = { const reducers = combineReducers({ fetchCount, settings: persistReducer(settingsPersistConfig, settingsReducer), - credentials2: persistReducer(credentialsPersistConfig, credentials), + credentials: persistReducer(credentialsPersistConfig, credentials), encryptionKey: persistReducer(encryptionKeyPersistConfig, encryptionKeyReducer), sync: persistReducer(syncPersistConfig, combineReducers({ collections: syncCollections, general: syncGeneral, })), - cache2: persistReducer(cachePersistConfig, combineReducers({ + cache: persistReducer(cachePersistConfig, combineReducers({ collections, items, })),