1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-01-06 00:07:44 +01:00
unleash.unleash/frontend/src/hooks/useGlobalLocalStorage.ts
2024-01-29 12:33:01 +01:00

25 lines
550 B
TypeScript

import { createLocalStorage } from 'utils/createLocalStorage';
interface IGlobalStore {
favorites?: boolean;
hiddenEnvironments?: Array<string>;
}
export const useGlobalLocalStorage = () => {
const { value, setValue } = createLocalStorage<IGlobalStore>(
'global:v1',
{},
);
// fix incorrect values introduced by a bug
const parsedValue = {
...value,
hiddenEnvironments: Array.from(value.hiddenEnvironments || []),
};
return {
value: parsedValue,
setValue,
};
};