use get-all to fetch frontend preferences

This commit is contained in:
Hazelnoot 2025-04-13 19:51:06 -04:00
parent a043333b3c
commit f43fde46fa

View file

@ -87,14 +87,17 @@ const storageProvider: StorageProvider = {
}, },
cloudGets: async (ctx) => { cloudGets: async (ctx) => {
// TODO: 値の取得を1つのリクエストで済ませたい(バックエンド側でAPIの新設が必要) const cloudDatas = await misskeyApi('i/registry/get-all', {
const fetchings = ctx.needs.map(need => storageProvider.cloudGet(need).then(res => [need.key, res] as const)); scope: ['client', 'preferences', 'sync'],
const cloudDatas = await Promise.all(fetchings); }) as Record<string, [any, any][] | undefined>;
const res = {} as Partial<Record<string, any>>; const res = {} as Partial<Record<string, any>>;
for (const cloudData of cloudDatas) { for (const need of ctx.needs) {
if (cloudData[1] != null) { const cloudData = cloudDatas[syncGroup + ':' + need.key];
res[cloudData[0]] = cloudData[1].value; const target = cloudData?.find(([scope]) => isSameScope(scope, need.scope));
if (target != null) {
res[need.key] = target[1];
} }
} }