Client: Support spool archiving in frontend

This commit is contained in:
Donkie
2023-07-14 14:21:47 +02:00
parent f89cf8ecd4
commit 7971cda7b5
7 changed files with 150 additions and 8 deletions

View File

@@ -59,3 +59,18 @@ export function useStoreInitialState(tableId: string, state: TableState) {
}
}, [tableId, state.showColumns]);
}
export function useShowArchive(tableId: string) {
const [showArchive, setShowArchive] = React.useState(() => {
const savedShowArchive = isLocalStorageAvailable ? localStorage.getItem(`${tableId}-showArchive`) : null;
return savedShowArchive ? JSON.parse(savedShowArchive) : false;
});
React.useEffect(() => {
if (isLocalStorageAvailable) {
localStorage.setItem(`${tableId}-showArchive`, JSON.stringify(showArchive));
}
}, [tableId, showArchive]);
return [showArchive, setShowArchive] as const;
}