refactor
This commit is contained in:
@@ -87,6 +87,21 @@ const storageProvider: StorageProvider = {
|
||||
value: cloudData,
|
||||
});
|
||||
},
|
||||
|
||||
cloudGets: async (ctx) => {
|
||||
// TODO: 値の取得を1つのリクエストで済ませたい(バックエンド側でAPIの新設が必要)
|
||||
const fetchings = ctx.needs.map(need => storageProvider.cloudGet(need).then(res => [need.key, res] as const));
|
||||
const cloudDatas = await Promise.all(fetchings);
|
||||
|
||||
const res = {} as Partial<Record<string, any>>;
|
||||
for (const cloudData of cloudDatas) {
|
||||
if (cloudData[1] != null) {
|
||||
res[cloudData[0]] = cloudData[1].value;
|
||||
}
|
||||
}
|
||||
|
||||
return res;
|
||||
},
|
||||
};
|
||||
|
||||
export const prefer = createProfileManager(storageProvider);
|
||||
|
Reference in New Issue
Block a user