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