From 41592eafb363e3c62ab2d3e5f41b38d7d083d3fb Mon Sep 17 00:00:00 2001 From: syuilo <4439005+syuilo@users.noreply.github.com> Date: Fri, 9 Jan 2026 22:06:40 +0900 Subject: refactor: make noImplicitAny true (#17083) * wip * Update emojis.emoji.vue * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * Update manager.ts * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * Update analytics.ts --- packages/frontend/src/store.ts | 86 ------------------------------------------ 1 file changed, 86 deletions(-) (limited to 'packages/frontend/src/store.ts') diff --git a/packages/frontend/src/store.ts b/packages/frontend/src/store.ts index fb9349c42f..44d8ed7293 100644 --- a/packages/frontend/src/store.ts +++ b/packages/frontend/src/store.ts @@ -478,89 +478,3 @@ interface Watcher { key: string; callback: (value: unknown) => void; } - -// TODO: 消す(preferに移行済みのため) -/** - * 常にメモリにロードしておく必要がないような設定情報を保管するストレージ(非リアクティブ) - */ -export class ColdDeviceStorage { - public static default = { - lightTheme, // TODO: 消す(preferに移行済みのため) - darkTheme, // TODO: 消す(preferに移行済みのため) - syncDeviceDarkMode: true, // TODO: 消す(preferに移行済みのため) - plugins: [] as (Omit & { id: string })[], // TODO: 消す(preferに移行済みのため) - }; - - public static watchers: Watcher[] = []; - - public static get(key: T): typeof ColdDeviceStorage.default[T] { - // TODO: indexedDBにする - // ただしその際はnullチェックではなくキー存在チェックにしないとダメ - // (indexedDBはnullを保存できるため、ユーザーが意図してnullを格納した可能性がある) - const value = miLocalStorage.getItem(`${PREFIX}${key}`); - if (value == null) { - return ColdDeviceStorage.default[key]; - } else { - return JSON.parse(value); - } - } - - public static getAll(): Partial { - 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; - }, {}); - } - - public static set(key: T, value: typeof ColdDeviceStorage.default[T]): void { - // 呼び出し側のバグ等で undefined が来ることがある - // undefined を文字列として miLocalStorage に入れると参照する際の JSON.parse でコケて不具合の元になるため無視 - - if (value === undefined) { - console.error(`attempt to store undefined value for key '${key}'`); - return; - } - - miLocalStorage.setItem(`${PREFIX}${key}`, JSON.stringify(value)); - - for (const watcher of this.watchers) { - if (watcher.key === key) watcher.callback(value); - } - } - - public static watch(key, callback) { - this.watchers.push({ key, callback }); - } - - // TODO: VueのcustomRef使うと良い感じになるかも - public static ref(key: T) { - const v = ColdDeviceStorage.get(key); - const r = ref(v); - // TODO: このままではwatcherがリークするので開放する方法を考える - this.watch(key, v => { - r.value = v; - }); - return r; - } - - /** - * 特定のキーの、簡易的なgetter/setterを作ります - * 主にvue場で設定コントロールのmodelとして使う用 - */ - public static makeGetterSetter(key: K) { - // TODO: VueのcustomRef使うと良い感じになるかも - const valueRef = ColdDeviceStorage.ref(key); - return { - get: () => { - return valueRef.value; - }, - set: (value: typeof ColdDeviceStorage.default[K]) => { - const val = value; - ColdDeviceStorage.set(key, val); - }, - }; - } -} -- cgit v1.2.3-freya