From be9d922047908a5481c2c766de0f7d1a0b004389 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Thu, 9 Mar 2023 15:35:50 -0600 Subject: [PATCH] Actually, do put relationships in their own list. And fix parsers not doing the right thing. --- app/soapbox/hooks/useGroups.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/soapbox/hooks/useGroups.ts b/app/soapbox/hooks/useGroups.ts index a8e61b9af..1c48e1e38 100644 --- a/app/soapbox/hooks/useGroups.ts +++ b/app/soapbox/hooks/useGroups.ts @@ -32,7 +32,7 @@ function useGroupRelationship(groupId: string) { function useGroupRelationships(groupIds: string[]) { const q = groupIds.map(id => `id[]=${id}`).join('&'); const endpoint = groupIds.length ? `/api/v1/groups/relationships?${q}` : undefined; - const { entities, ...result } = useEntities(['GroupRelationship', ''], endpoint, { parser: parseGroupRelationship }); + const { entities, ...result } = useEntities(['GroupRelationship', q], endpoint, { parser: parseGroupRelationship }); const relationships = entities.reduce>((map, relationship) => { map[relationship.id] = relationship; @@ -47,7 +47,7 @@ function useGroupRelationships(groupIds: string[]) { // HACK: normalizers currently don't have the desired API. // TODO: rewrite normalizers as Zod parsers. -const parseGroup = (entity: unknown) => normalizeGroup(entity as Record); -const parseGroupRelationship = (entity: unknown) => normalizeGroupRelationship(entity as Record); +const parseGroup = (entity: unknown) => entity ? normalizeGroup(entity as Record) : undefined; +const parseGroupRelationship = (entity: unknown) => entity ? normalizeGroupRelationship(entity as Record) : undefined; export { useGroup, useGroups }; \ No newline at end of file