This commit is contained in:
tamaina
2022-11-24 18:27:05 +09:00
parent 11d2654ffc
commit 8b9dc962ae
7 changed files with 83 additions and 212 deletions

View File

@@ -303,16 +303,6 @@ 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 {
// 呼び出し側のバグ等で undefined が来ることがある
// undefined を文字列として localStorage に入れると参照する際の JSON.parse でコケて不具合の元になるため無視