Revert useEntity array changes, do that in the schema parser
This commit is contained in:
parent
6b30671875
commit
74ebd560e6
2 changed files with 4 additions and 2 deletions
|
@ -39,7 +39,7 @@ function useEntity<TEntity extends Entity>(
|
|||
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(() => {
|
||||
|
|
|
@ -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<GroupRelationship>(
|
||||
[Entities.GROUP_RELATIONSHIPS, groupId],
|
||||
`/api/v1/groups/relationships?id[]=${groupId}`,
|
||||
{ schema: groupRelationshipSchema },
|
||||
{ schema: z.array(groupRelationshipSchema).transform(arr => arr[0]) },
|
||||
);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue