From 688bdccc248a02f0a11e1036215d86804d57348a Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Wed, 26 Oct 2022 18:25:56 +0200 Subject: [PATCH] Fix accepting group invitations Closes #1170 Signed-off-by: Thomas Citharel --- js/src/components/Group/InvitationsList.vue | 70 +++++++++++---------- 1 file changed, 38 insertions(+), 32 deletions(-) diff --git a/js/src/components/Group/InvitationsList.vue b/js/src/components/Group/InvitationsList.vue index 4802671f9..bb810b598 100644 --- a/js/src/components/Group/InvitationsList.vue +++ b/js/src/components/Group/InvitationsList.vue @@ -4,8 +4,8 @@ v-for="member in invitations" :key="member.id" :member="member" - @accept="acceptInvitation" - @reject="rejectInvitation" + @accept="acceptInvitation({ id: member.id })" + @reject="rejectInvitation({ id: member.id })" /> @@ -25,21 +25,24 @@ defineProps<{ }>(); const { mutate: acceptInvitation, onError: onAcceptInvitationError } = - useMutation(ACCEPT_INVITATION, { - refetchQueries({ data }) { - const profile = data?.acceptInvitation?.actor as IPerson; - const group = data?.acceptInvitation?.parent as IGroup; - if (profile && group) { - return [ - { - query: PERSON_STATUS_GROUP, - variables: { id: profile.id, group: usernameWithDomain(group) }, - }, - ]; - } - return []; - }, - }); + useMutation<{ acceptInvitation: IMember }, { id: string }>( + ACCEPT_INVITATION, + { + refetchQueries({ data }) { + const profile = data?.acceptInvitation?.actor as IPerson; + const group = data?.acceptInvitation?.parent as IGroup; + if (profile && group) { + return [ + { + query: PERSON_STATUS_GROUP, + variables: { id: profile.id, group: usernameWithDomain(group) }, + }, + ]; + } + return []; + }, + } + ); const notifier = inject("notifier"); @@ -53,21 +56,24 @@ const onError = (error: ErrorResponse) => { onAcceptInvitationError((err) => onError(err as unknown as ErrorResponse)); const { mutate: rejectInvitation, onError: onRejectInvitationError } = - useMutation(REJECT_INVITATION, { - refetchQueries({ data }) { - const profile = data?.rejectInvitation?.actor as IPerson; - const group = data?.rejectInvitation?.parent as IGroup; - if (profile && group) { - return [ - { - query: PERSON_STATUS_GROUP, - variables: { id: profile.id, group: usernameWithDomain(group) }, - }, - ]; - } - return []; - }, - }); + useMutation<{ rejectInvitation: IMember }, { id: string }>( + REJECT_INVITATION, + { + refetchQueries({ data }) { + const profile = data?.rejectInvitation?.actor as IPerson; + const group = data?.rejectInvitation?.parent as IGroup; + if (profile && group) { + return [ + { + query: PERSON_STATUS_GROUP, + variables: { id: profile.id, group: usernameWithDomain(group) }, + }, + ]; + } + return []; + }, + } + ); onRejectInvitationError((err) => onError(err as unknown as ErrorResponse));