specal-case cloudGets for empty request/response

as the comment says, frontend boot calls `cloudGets` with an empty
`needs`, and upstream's code returns an empty object without calling
the API (because the call `i/registry/get` for each element in
`needs`), but we have to special-case it
This commit is contained in:
dakkar 2025-04-14 17:14:43 +01:00
parent 31249a571f
commit ab572a6ed6

View file

@ -87,6 +87,13 @@ const storageProvider: StorageProvider = {
}, },
cloudGets: async (ctx) => { cloudGets: async (ctx) => {
/* this happens when the frontend boots and there's no logged-in
user; we can't call `i/registry/get-all` because that would
fail, but also we don't need to: return the empty result that
the caller asked for */
if (ctx.needs.length === 0) {
return {};
}
const cloudDatas = await misskeyApi('i/registry/get-all', { const cloudDatas = await misskeyApi('i/registry/get-all', {
scope: ['client', 'preferences', 'sync'], scope: ['client', 'preferences', 'sync'],
}) as Record<string, [any, any][] | undefined>; }) as Record<string, [any, any][] | undefined>;