feature: Client Preferences Registry on the account

This commit is contained in:
tamaina
2022-04-17 05:12:33 +09:00
parent 55c6f5a740
commit 39e4f2c137
4 changed files with 315 additions and 0 deletions

View File

@@ -286,6 +286,16 @@ export class ColdDeviceStorage {
}
}
public static getAll(): Partial<typeof this.default> {
return (Object.keys(this.default) as (keyof typeof this.default)[]).reduce((acc, key) => {
const value = localStorage.getItem(PREFIX + key);
if (value != null) {
acc[key] = JSON.parse(value);
}
return acc;
}, {} as any);
}
public static set<T extends keyof typeof ColdDeviceStorage.default>(key: T, value: typeof ColdDeviceStorage.default[T]): void {
localStorage.setItem(PREFIX + key, JSON.stringify(value));