mirror of
https://codeberg.org/yeentown/barkey.git
synced 2025-07-07 12:36:57 +00:00
use get-all to fetch frontend preferences
This commit is contained in:
parent
a043333b3c
commit
f43fde46fa
1 changed files with 9 additions and 6 deletions
|
@ -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];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue