Fix useRelationships hook
This commit is contained in:
parent
989d99f908
commit
bfe6ab3c26
1 changed files with 6 additions and 2 deletions
|
@ -7,12 +7,16 @@ import { type Relationship, relationshipSchema } from 'soapbox/schemas';
|
|||
function useRelationships(listKey: string[], ids: string[]) {
|
||||
const api = useApi();
|
||||
const { isLoggedIn } = useLoggedIn();
|
||||
const q = ids.map(id => `id[]=${id}`).join('&');
|
||||
|
||||
function fetchRelationships(ids: string[]) {
|
||||
const q = ids.map((id) => `id[]=${id}`).join('&');
|
||||
return api.get(`/api/v1/accounts/relationships?${q}`);
|
||||
}
|
||||
|
||||
const { entityMap: relationships, ...result } = useBatchedEntities<Relationship>(
|
||||
[Entities.RELATIONSHIPS, ...listKey],
|
||||
ids,
|
||||
() => api.get(`/api/v1/accounts/relationships?${q}`),
|
||||
fetchRelationships,
|
||||
{ schema: relationshipSchema, enabled: isLoggedIn },
|
||||
);
|
||||
|
||||
|
|
Loading…
Reference in a new issue