2023-07-27 05:31:52 +00:00
|
|
|
|
/*
|
2024-02-13 15:59:27 +00:00
|
|
|
|
* SPDX-FileCopyrightText: syuilo and misskey-project
|
2023-07-27 05:31:52 +00:00
|
|
|
|
* SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
*/
|
|
|
|
|
|
2024-09-09 11:57:36 +00:00
|
|
|
|
export type Keys =
|
2023-01-07 01:13:02 +00:00
|
|
|
|
'v' |
|
|
|
|
|
'lastVersion' |
|
|
|
|
|
'instance' |
|
2024-02-23 01:47:17 +00:00
|
|
|
|
'instanceCachedAt' |
|
2023-01-07 01:13:02 +00:00
|
|
|
|
'account' |
|
|
|
|
|
'accounts' |
|
2023-01-07 02:49:00 +00:00
|
|
|
|
'latestDonationInfoShownAt' |
|
|
|
|
|
'neverShowDonationInfo' |
|
2023-04-05 05:30:03 +00:00
|
|
|
|
'neverShowLocalOnlyInfo' |
|
2024-02-17 04:34:50 +00:00
|
|
|
|
'modifiedVersionMustProminentlyOfferInAgplV3Section13Read' |
|
2023-01-07 01:13:02 +00:00
|
|
|
|
'lastUsed' |
|
|
|
|
|
'lang' |
|
|
|
|
|
'drafts' |
|
|
|
|
|
'hashtags' |
|
|
|
|
|
'wallpaper' |
|
|
|
|
|
'theme' |
|
2023-06-05 01:55:18 +00:00
|
|
|
|
'colorScheme' |
|
2023-07-07 22:08:16 +00:00
|
|
|
|
'useSystemFont' |
|
2023-01-07 01:13:02 +00:00
|
|
|
|
'fontSize' |
|
|
|
|
|
'ui' |
|
2023-01-27 04:52:51 +00:00
|
|
|
|
'ui_temp' |
|
2023-01-07 01:13:02 +00:00
|
|
|
|
'locale' |
|
2023-01-21 11:24:15 +00:00
|
|
|
|
'localeVersion' |
|
2023-01-07 01:13:02 +00:00
|
|
|
|
'theme' |
|
|
|
|
|
'customCss' |
|
|
|
|
|
'message_drafts' |
|
|
|
|
|
'scratchpad' |
|
2023-04-13 09:47:49 +00:00
|
|
|
|
'debug' |
|
2023-01-07 01:13:02 +00:00
|
|
|
|
`miux:${string}` |
|
|
|
|
|
`ui:folder:${string}` |
|
|
|
|
|
`themes:${string}` |
|
2023-02-28 11:10:52 +00:00
|
|
|
|
`aiscript:${string}` |
|
|
|
|
|
'lastEmojisFetchedAt' | // DEPRECATED, stored in indexeddb (13.9.0~)
|
2023-12-22 11:41:42 +00:00
|
|
|
|
'emojis' | // DEPRECATED, stored in indexeddb (13.9.0~);
|
2024-09-09 11:57:36 +00:00
|
|
|
|
`channelLastReadedAt:${string}` |
|
|
|
|
|
`idbfallback::${string}`
|
|
|
|
|
|
|
|
|
|
// セッション毎に廃棄されるLocalStorage代替(セーフモードなどで使用できそう)
|
|
|
|
|
//const safeSessionStorage = new Map<Keys, string>();
|
2023-01-07 01:13:02 +00:00
|
|
|
|
|
|
|
|
|
export const miLocalStorage = {
|
2024-09-09 11:57:36 +00:00
|
|
|
|
getItem: (key: Keys): string | null => {
|
|
|
|
|
return 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 08:40:59 +00:00
|
|
|
|
getItemAsJson: (key: Keys): any | undefined => {
|
|
|
|
|
const item = miLocalStorage.getItem(key);
|
|
|
|
|
if (item === null) {
|
|
|
|
|
return undefined;
|
|
|
|
|
}
|
|
|
|
|
return JSON.parse(item);
|
|
|
|
|
},
|
2024-09-09 11:57:36 +00:00
|
|
|
|
setItemAsJson: (key: Keys, value: any): void => {
|
|
|
|
|
miLocalStorage.setItem(key, JSON.stringify(value));
|
|
|
|
|
},
|
2023-01-07 01:13:02 +00:00
|
|
|
|
};
|