kopia lustrzana https://gitlab.com/soapbox-pub/soapbox
Fix parser
rodzic
9d1c2df1a2
commit
1d53f48904
|
@ -2,18 +2,11 @@ import { Entities } from 'soapbox/entity-store/entities';
|
|||
import { useEntities } from 'soapbox/entity-store/hooks';
|
||||
import { GroupMember, groupMemberSchema } from 'soapbox/schemas';
|
||||
|
||||
const parseGroupMember = (entity: unknown) => {
|
||||
const result = groupMemberSchema.safeParse(entity);
|
||||
if (result.success) {
|
||||
return result.data;
|
||||
}
|
||||
};
|
||||
|
||||
function useGroupMembers(groupId: string, role: string) {
|
||||
const { entities, ...result } = useEntities<GroupMember>(
|
||||
[Entities.GROUP_MEMBERSHIPS, groupId, role],
|
||||
`/api/v1/groups/${groupId}/memberships?role=${role}&limit=1`,
|
||||
{ parser: parseGroupMember },
|
||||
`/api/v1/groups/${groupId}/memberships?role=${role}`,
|
||||
{ schema: groupMemberSchema },
|
||||
);
|
||||
|
||||
return {
|
||||
|
|
Ładowanie…
Reference in New Issue