fix: replace individual delete calls with delMany for improved efficiency

This commit is contained in:
kakkokari-gtyih 2025-12-27 15:43:08 +09:00
parent a2250a2733
commit 821d23855c
2 changed files with 10 additions and 3 deletions

View File

@ -12,7 +12,7 @@ import { BroadcastChannel } from 'broadcast-channel';
import type { Ref } from 'vue';
import { $i } from '@/i.js';
import { misskeyApi } from '@/utility/misskey-api.js';
import { get, set, del } from '@/utility/idb-proxy.js';
import { get, set, delMany } from '@/utility/idb-proxy.js';
import { store } from '@/store.js';
import { deepClone } from '@/utility/clone.js';
import { deepMerge } from '@/utility/merge.js';
@ -230,8 +230,7 @@ export class Pizzax<T extends StateDef> {
const registryCacheKey = `pizzax::${this.key}::cache::${id}` satisfies typeof this.registryCacheKeyName;
await this.addIdbSetJob(async () => {
await del(deviceAccountStateKey);
await del(registryCacheKey);
await delMany([deviceAccountStateKey, registryCacheKey]);
});
}

View File

@ -9,6 +9,7 @@ import {
get as iget,
set as iset,
del as idel,
delMany as idelMany,
clear as iclear,
} from 'idb-keyval';
import { miLocalStorage } from '@/local-storage.js';
@ -53,6 +54,13 @@ export async function del(key: string) {
return miLocalStorage.removeItem(`${PREFIX}${key}`);
}
export async function delMany(keys: string[]) {
if (idbAvailable) return idelMany(keys);
for (const key of keys) {
miLocalStorage.removeItem(`${PREFIX}${key}`);
}
}
export async function clear() {
if (idbAvailable) return iclear();
}