diff --git a/app/soapbox/features/group/components/group-action-button.tsx b/app/soapbox/features/group/components/group-action-button.tsx index f7bf141107..45e8534b97 100644 --- a/app/soapbox/features/group/components/group-action-button.tsx +++ b/app/soapbox/features/group/components/group-action-button.tsx @@ -3,14 +3,14 @@ import { defineMessages, FormattedMessage, useIntl } from 'react-intl'; import { openModal } from 'soapbox/actions/modals'; import { Button } from 'soapbox/components/ui'; -import { deleteEntities } from 'soapbox/entity-store/actions'; +import { importEntities } from 'soapbox/entity-store/actions'; import { Entities } from 'soapbox/entity-store/entities'; import { useAppDispatch } from 'soapbox/hooks'; import { useCancelMembershipRequest, useJoinGroup, useLeaveGroup } from 'soapbox/hooks/api'; import { GroupRoles } from 'soapbox/schemas/group-member'; import toast from 'soapbox/toast'; -import type { Group } from 'soapbox/types/entities'; +import type { Group, GroupRelationship } from 'soapbox/types/entities'; interface IGroupActionButton { group: Group @@ -66,7 +66,11 @@ const GroupActionButton = ({ group }: IGroupActionButton) => { const onCancelRequest = () => cancelRequest.mutate({}, { onSuccess() { - dispatch(deleteEntities([group.id], Entities.GROUP_RELATIONSHIPS)); + const entity = { + ...group.relationship as GroupRelationship, + requested: false, + }; + dispatch(importEntities([entity], Entities.GROUP_RELATIONSHIPS)); }, }); diff --git a/app/soapbox/hooks/api/groups/useCancelMembershipRequest.ts b/app/soapbox/hooks/api/groups/useCancelMembershipRequest.ts index 3aad33f9c5..c8b650dee4 100644 --- a/app/soapbox/hooks/api/groups/useCancelMembershipRequest.ts +++ b/app/soapbox/hooks/api/groups/useCancelMembershipRequest.ts @@ -1,15 +1,16 @@ import { Entities } from 'soapbox/entity-store/entities'; -import { useEntityActions } from 'soapbox/entity-store/hooks'; -import { useOwnAccount } from 'soapbox/hooks'; +import { useCreateEntity } from 'soapbox/entity-store/hooks'; +import { useApi, useOwnAccount } from 'soapbox/hooks'; -import type { Group, GroupRelationship } from 'soapbox/schemas'; +import type { Group } from 'soapbox/schemas'; function useCancelMembershipRequest(group: Group) { + const api = useApi(); const me = useOwnAccount(); - const { createEntity, isLoading } = useEntityActions( - [Entities.GROUP_RELATIONSHIPS, group.id], - { post: `/api/v1/groups/${group.id}/membership_requests/${me?.id}/reject` }, + const { createEntity, isLoading } = useCreateEntity( + [Entities.GROUP_RELATIONSHIPS], + () => api.post(`/api/v1/groups/${group.id}/membership_requests/${me?.id}/reject`), ); return {