diff --git a/app/soapbox/entity-store/hooks/useEntity.ts b/app/soapbox/entity-store/hooks/useEntity.ts index 3c4b9cce7c..1dad1ff1e3 100644 --- a/app/soapbox/entity-store/hooks/useEntity.ts +++ b/app/soapbox/entity-store/hooks/useEntity.ts @@ -39,7 +39,7 @@ function useEntity( const fetchEntity = () => { setIsFetching(true); api.get(endpoint).then(({ data }) => { - const entity = schema.parse(Array.isArray(data) ? data[0] : data); + const entity = schema.parse(data); dispatch(importEntities([entity], entityType)); setIsFetching(false); }).catch(() => { diff --git a/app/soapbox/hooks/useGroups.ts b/app/soapbox/hooks/useGroups.ts index 7ce158c979..865896e24f 100644 --- a/app/soapbox/hooks/useGroups.ts +++ b/app/soapbox/hooks/useGroups.ts @@ -1,3 +1,5 @@ +import { z } from 'zod'; + import { Entities } from 'soapbox/entity-store/entities'; import { useEntities, useEntity } from 'soapbox/entity-store/hooks'; import { groupSchema, Group } from 'soapbox/schemas/group'; @@ -40,7 +42,7 @@ function useGroupRelationship(groupId: string) { return useEntity( [Entities.GROUP_RELATIONSHIPS, groupId], `/api/v1/groups/relationships?id[]=${groupId}`, - { schema: groupRelationshipSchema }, + { schema: z.array(groupRelationshipSchema).transform(arr => arr[0]) }, ); }