Add persistance

This commit is contained in:
2025-10-20 15:40:48 +02:00
parent 6dedd2f75e
commit 1179694c00
3 changed files with 57 additions and 12 deletions

View File

@@ -5,20 +5,42 @@ import {
// Using localStorage for persistance
const persistanceStore: PersistanceConfig = JSON.parse( localStorage.getItem( 'persistance' ) ?? '{}' );
export const store = (
/**
* Store state for filename.
* @param filename - The filename to store for
* @param size - The filesize (in case file is changed)
* @param sorted - The sorted column
* @param active - The active column
* @param ascending - True if sorting ascending
*/
const store = (
filename: string,
size: number,
size: string,
sorted: string,
active: string
active: string,
ascending: boolean
) => {
persistanceStore[ `${ filename }-${ size }` ] = {
'active': active,
'sorted': sorted
'sorted': sorted,
'ascending': ascending
};
localStorage.setItem( 'persistance', JSON.stringify( persistanceStore ) );
};
export const get = ( filename: string, size: number ) => {
/**
* Get the state for filename
* @param filename - The file to retrieve from
* @param size - The size of the file
* @returns The state, if found
*/
const get = ( filename: string, size: string ) => {
return persistanceStore[ `${ filename }-${ size }` ];
};
export default {
store,
get
};