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.
master
Tom Hacohen 4 years ago
parent 1268564b90
commit e58f3dd9e6

@ -17,8 +17,8 @@ export default function Debug() {
const [stateCollectionUid, setCollectionUid] = React.useState(""); const [stateCollectionUid, setCollectionUid] = React.useState("");
const [itemsUids, setEntriesUids] = React.useState(""); const [itemsUids, setEntriesUids] = React.useState("");
const [result, setResult] = React.useState(""); const [result, setResult] = React.useState("");
const cacheCollections = useSelector((state: StoreState) => state.cache2.collections); const cacheCollections = useSelector((state: StoreState) => state.cache.collections);
const cacheItems = useSelector((state: StoreState) => state.cache2.items); const cacheItems = useSelector((state: StoreState) => state.cache.items);
function handleInputChange(func: (value: string) => void) { function handleInputChange(func: (value: string) => void) {
return (event: React.ChangeEvent<any>) => { return (event: React.ChangeEvent<any>) => {

@ -10,7 +10,7 @@ import * as store from "./store";
import { usePromiseMemo } from "./helpers"; import { usePromiseMemo } from "./helpers";
export const credentialsSelector = createSelector( export const credentialsSelector = createSelector(
(state: store.StoreState) => state.credentials2.storedSession, (state: store.StoreState) => state.credentials.storedSession,
(storedSession) => { (storedSession) => {
if (storedSession) { if (storedSession) {
return Etebase.Account.restore(storedSession); return Etebase.Account.restore(storedSession);

@ -58,7 +58,7 @@ export const getCollectionManager = memoize(function (etebase: Etebase.Account)
// React specific stuff // React specific stuff
export function useCollections(etebase: Etebase.Account, colType?: string) { 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( return usePromiseMemo(
(colType) ? (colType) ?
getCollectionsByType(cachedCollections, colType, etebase) : getCollectionsByType(cachedCollections, colType, etebase) :
@ -68,8 +68,8 @@ export function useCollections(etebase: Etebase.Account, colType?: string) {
} }
export function useItems(etebase: Etebase.Account, colType: string) { export function useItems(etebase: Etebase.Account, colType: string) {
const cachedCollections = useSelector((state: StoreState) => state.cache2.collections); const cachedCollections = useSelector((state: StoreState) => state.cache.collections);
const cachedItems = useSelector((state: StoreState) => state.cache2.items); const cachedItems = useSelector((state: StoreState) => state.cache.items);
return usePromiseMemo( return usePromiseMemo(
getItemsByType(cachedCollections, cachedItems, colType, etebase), getItemsByType(cachedCollections, cachedItems, colType, etebase),
[etebase, cachedCollections, cachedItems, colType] [etebase, cachedCollections, cachedItems, colType]

@ -18,14 +18,14 @@ import {
export interface StoreState { export interface StoreState {
fetchCount: number; fetchCount: number;
credentials2: CredentialsData; credentials: CredentialsData;
settings: SettingsType; settings: SettingsType;
encryptionKey: {key: string}; encryptionKey: {key: string};
sync: { sync: {
collections: SyncCollectionsData; collections: SyncCollectionsData;
general: SyncGeneralData; general: SyncGeneralData;
}; };
cache2: { cache: {
collections: CacheCollectionsData; collections: CacheCollectionsData;
items: CacheItemsData; items: CacheItemsData;
}; };
@ -124,13 +124,13 @@ const cachePersistConfig = {
const reducers = combineReducers({ const reducers = combineReducers({
fetchCount, fetchCount,
settings: persistReducer(settingsPersistConfig, settingsReducer), settings: persistReducer(settingsPersistConfig, settingsReducer),
credentials2: persistReducer(credentialsPersistConfig, credentials), credentials: 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(cachePersistConfig, combineReducers({ cache: persistReducer(cachePersistConfig, combineReducers({
collections, collections,
items, items,
})), })),

Loading…
Cancel
Save