forked from potsda.mn/mobilizon
Fix accepting group invitations
Closes #1170 Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
parent
e446df938f
commit
688bdccc24
|
@ -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 })"
|
||||
/>
|
||||
</section>
|
||||
</template>
|
||||
|
@ -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>("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));
|
||||
</script>
|
||||
|
|
Loading…
Reference in a new issue