From bfe6ab3c265cde93387b4944321ffa8ff547a11f Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Sun, 25 Jun 2023 16:11:00 -0500 Subject: [PATCH] Fix useRelationships hook --- app/soapbox/api/hooks/accounts/useRelationships.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/soapbox/api/hooks/accounts/useRelationships.ts b/app/soapbox/api/hooks/accounts/useRelationships.ts index f145a8a5cb..49a03f5eba 100644 --- a/app/soapbox/api/hooks/accounts/useRelationships.ts +++ b/app/soapbox/api/hooks/accounts/useRelationships.ts @@ -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( [Entities.RELATIONSHIPS, ...listKey], ids, - () => api.get(`/api/v1/accounts/relationships?${q}`), + fetchRelationships, { schema: relationshipSchema, enabled: isLoggedIn }, );