enhance(frontend): cache user lists / antennas

This commit is contained in:
syuilo
2023-09-10 17:40:59 +09:00
parent b434beb5e2
commit 85078601c2
3 changed files with 26 additions and 2 deletions

View File

@@ -30,6 +30,8 @@ type Keys =
'message_drafts' |
'scratchpad' |
'debug' |
'userListsCache' |
'antennasCache' |
`miux:${string}` |
`ui:folder:${string}` |
`themes:${string}` |
@@ -41,4 +43,12 @@ export const miLocalStorage = {
getItem: (key: Keys): string | null => window.localStorage.getItem(key),
setItem: (key: Keys, value: string): void => window.localStorage.setItem(key, value),
removeItem: (key: Keys): void => window.localStorage.removeItem(key),
getItemAsJson: (key: Keys): any | undefined => {
const item = miLocalStorage.getItem(key);
if (item === null) {
return undefined;
}
return JSON.parse(item);
},
setItemAsJson: (key: Keys, value: any): void => window.localStorage.setItem(key, JSON.stringify(value)),
};