2023-07-26 22:31:52 -07:00
|
|
|
/*
|
|
|
|
* SPDX-FileCopyrightText: syuilo and other misskey contributors
|
|
|
|
* SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
*/
|
|
|
|
|
2023-01-06 17:13:02 -08:00
|
|
|
type Keys =
|
|
|
|
'v' |
|
|
|
|
'lastVersion' |
|
|
|
|
'instance' |
|
|
|
|
'account' |
|
|
|
|
'accounts' |
|
2023-01-06 18:49:00 -08:00
|
|
|
'latestDonationInfoShownAt' |
|
|
|
|
'neverShowDonationInfo' |
|
2023-04-04 22:30:03 -07:00
|
|
|
'neverShowLocalOnlyInfo' |
|
2023-01-06 17:13:02 -08:00
|
|
|
'lastUsed' |
|
|
|
|
'lang' |
|
|
|
|
'drafts' |
|
|
|
|
'hashtags' |
|
|
|
|
'wallpaper' |
|
|
|
|
'theme' |
|
2023-06-04 18:55:18 -07:00
|
|
|
'colorScheme' |
|
2023-07-07 15:08:16 -07:00
|
|
|
'useSystemFont' |
|
2023-01-06 17:13:02 -08:00
|
|
|
'fontSize' |
|
|
|
|
'ui' |
|
2023-01-26 20:52:51 -08:00
|
|
|
'ui_temp' |
|
2023-01-06 17:13:02 -08:00
|
|
|
'locale' |
|
2023-01-21 03:24:15 -08:00
|
|
|
'localeVersion' |
|
2023-01-06 17:13:02 -08:00
|
|
|
'theme' |
|
|
|
|
'customCss' |
|
|
|
|
'message_drafts' |
|
|
|
|
'scratchpad' |
|
2023-04-13 02:47:49 -07:00
|
|
|
'debug' |
|
2023-01-06 17:13:02 -08:00
|
|
|
`miux:${string}` |
|
|
|
|
`ui:folder:${string}` |
|
|
|
|
`themes:${string}` |
|
2023-02-28 03:10:52 -08:00
|
|
|
`aiscript:${string}` |
|
|
|
|
'lastEmojisFetchedAt' | // DEPRECATED, stored in indexeddb (13.9.0~)
|
|
|
|
'emojis' // DEPRECATED, stored in indexeddb (13.9.0~);
|
2023-01-06 17:13:02 -08:00
|
|
|
|
|
|
|
export const miLocalStorage = {
|
2023-04-13 02:47:49 -07:00
|
|
|
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),
|
2023-09-10 01:40:59 -07:00
|
|
|
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)),
|
2023-01-06 17:13:02 -08:00
|
|
|
};
|