diff options
| author | tamaina <tamaina@hotmail.co.jp> | 2021-12-30 02:03:39 +0900 |
|---|---|---|
| committer | tamaina <tamaina@hotmail.co.jp> | 2021-12-30 02:03:39 +0900 |
| commit | 14e74beba13009fde35db75a1db7a999e1967733 (patch) | |
| tree | 19715cc18b1a5b6d632aeb0145c22e189a1c04f5 | |
| parent | :v: (diff) | |
| download | misskey-14e74beba13009fde35db75a1db7a999e1967733.tar.gz misskey-14e74beba13009fde35db75a1db7a999e1967733.tar.bz2 misskey-14e74beba13009fde35db75a1db7a999e1967733.zip | |
:v:
Diffstat (limited to '')
| -rw-r--r-- | packages/client/src/pizzax.ts | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/packages/client/src/pizzax.ts b/packages/client/src/pizzax.ts index 479799d1f9..1a48dc0a2c 100644 --- a/packages/client/src/pizzax.ts +++ b/packages/client/src/pizzax.ts @@ -117,35 +117,37 @@ export class Storage<T extends StateDef> { } public set<K extends keyof T>(key: K, value: T[K]['default']): Promise<void> { - if (_DEV_) console.log('set', key, value); + const rawValue = JSON.parse(JSON.stringify(value)); - this.state[key] = value; - this.reactiveState[key].value = value; + if (_DEV_) console.log('set', key, rawValue, value); + + this.state[key] = rawValue; + this.reactiveState[key].value = rawValue; return this.addIdbSetJob(async () => { switch (this.def[key].where) { case 'device': { const deviceState = await get(this.deviceStateKeyName) || {}; - deviceState[key] = value; + deviceState[key] = rawValue; await set(this.deviceStateKeyName, deviceState); break; } case 'deviceAccount': { if ($i == null) break; const deviceAccountState = await get(this.deviceAccountStateKeyName) || {}; - deviceAccountState[key] = value; + deviceAccountState[key] = rawValue; await set(this.deviceAccountStateKeyName, deviceAccountState); break; } case 'account': { if ($i == null) break; const cache = await get(this.registryCacheKeyName) || {}; - cache[key] = value; + cache[key] = rawValue; await set(this.registryCacheKeyName, cache); await api('i/registry/set', { scope: ['client', this.key], key: key, - value: value + value: rawValue }); break; } |