grid, interface: fix localStorage versioning

This commit is contained in:
Liam Fitzgerald 2021-09-24 10:08:23 +10:00
parent e1ee384e05
commit b532e629f3
2 changed files with 4 additions and 6 deletions

View File

@ -74,7 +74,7 @@ export const optReduceState = <S extends Record<string, unknown>, U>(
export let stateStorageKeys: string[] = []; export let stateStorageKeys: string[] = [];
export const stateStorageKey = (stateName: string) => { export const stateStorageKey = (stateName: string) => {
stateName = `Landscape${stateName}State`; stateName = `Grid${stateName}State-${import.meta.env.VITE_SHORTHASH as any}`;
stateStorageKeys = [...new Set([...stateStorageKeys, stateName])]; stateStorageKeys = [...new Set([...stateStorageKeys, stateName])];
return stateName; return stateName;
}; };
@ -149,8 +149,7 @@ export const createState = <T extends Record<string, unknown>>(
}), }),
{ {
blacklist, blacklist,
name: stateStorageKey(name), name: stateStorageKey(name)
version: import.meta.env.VITE_SHORTHASH as any
} }
) )
); );

View File

@ -73,7 +73,7 @@ export const optReduceState = <S, U>(
export let stateStorageKeys: string[] = []; export let stateStorageKeys: string[] = [];
export const stateStorageKey = (stateName: string) => { export const stateStorageKey = (stateName: string) => {
stateName = `Landscape${stateName}State`; stateName = `Landscape${stateName}State-${process.env.LANDSCAPE_SHORTHASH}`;
stateStorageKeys = [...new Set([...stateStorageKeys, stateName])]; stateStorageKeys = [...new Set([...stateStorageKeys, stateName])];
return stateName; return stateName;
}; };
@ -140,8 +140,7 @@ export const createState = <T extends {}>(
...(typeof properties === 'function' ? (properties as any)(set, get) : properties) ...(typeof properties === 'function' ? (properties as any)(set, get) : properties)
}), { }), {
blacklist, blacklist,
name: stateStorageKey(name), name: stateStorageKey(name)
version: process.env.LANDSCAPE_SHORTHASH as any
})); }));
export async function doOptimistically<A, S extends {}>(state: UseStore<S & BaseState<S>>, action: A, call: (a: A) => Promise<any>, reduce: ((a: A, fn: S & BaseState<S>) => S & BaseState<S>)[]) { export async function doOptimistically<A, S extends {}>(state: UseStore<S & BaseState<S>>, action: A, call: (a: A) => Promise<any>, reduce: ((a: A, fn: S & BaseState<S>) => S & BaseState<S>)[]) {