1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-07-21 13:47:39 +02:00
unleash.unleash/frontend/src/hooks/useGlobalLocalStorage.ts
Tymoteusz Czech 2a6487e7e9
feat: show and hide environments (#9323)
- Button to show and hide environments
- Refactored hook storing state of hidden environments
- Changed the way flag is triggered for feature overview
- Visual updates for new page look

---------

Co-authored-by: Thomas Heartman <thomas@getunleash.io>
2025-02-19 09:48:07 +00:00

28 lines
620 B
TypeScript

import { createLocalStorage } from 'utils/createLocalStorage';
interface IGlobalStore {
favorites?: boolean;
hiddenEnvironments?: Array<string>;
}
/**
* @deprecated use tested `useLocalStorageState` hook instead
*/
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,
};
};