fix: fetch discussion and ressources info when accepting a group invitation
Also ensure that the actor is included in PERSON_STATUS_GROUP, to stay consistent with LOGGED_USER_MEMBERSHIPS as used in MyGroups.vue. The accept-invitation and refuse-invitation events needed to be emitted before refetching PERSON_STATUS_GROUP, so they can be caught by GroupView.vue before <InvitationsList> is destroyed due to the v-if becoming false. Fixes #1800
This commit is contained in:
@@ -29,14 +29,19 @@ const emit = defineEmits<{
|
||||
(e: "reject-invitation", member: IMember): void;
|
||||
}>();
|
||||
|
||||
const {
|
||||
mutate: acceptInvitation,
|
||||
onDone: onAcceptInvitationDone,
|
||||
onError: onAcceptInvitationError,
|
||||
} = useMutation<{ acceptInvitation: IMember }, { id: string }>(
|
||||
const { mutate: acceptInvitation, onError: onAcceptInvitationError } =
|
||||
useMutation<{ acceptInvitation: IMember }, { id: string }>(
|
||||
ACCEPT_INVITATION,
|
||||
{
|
||||
refetchQueries({ data }) {
|
||||
if (!data?.acceptInvitation) {
|
||||
console.error(data);
|
||||
alert("Error while accepting invitation");
|
||||
return [];
|
||||
}
|
||||
|
||||
emit("accept-invitation", data?.acceptInvitation);
|
||||
|
||||
const profile = data?.acceptInvitation?.actor as IPerson;
|
||||
const group = data?.acceptInvitation?.parent as IGroup;
|
||||
if (profile && group) {
|
||||
@@ -61,25 +66,21 @@ const onError = (error: ErrorResponse) => {
|
||||
}
|
||||
};
|
||||
|
||||
onAcceptInvitationDone((result) => {
|
||||
if (!result.data?.acceptInvitation) {
|
||||
console.error(result);
|
||||
alert("Error while accepting invitation");
|
||||
return;
|
||||
}
|
||||
emit("accept-invitation", result.data?.acceptInvitation);
|
||||
});
|
||||
|
||||
onAcceptInvitationError((err) => onError(err as unknown as ErrorResponse));
|
||||
|
||||
const {
|
||||
mutate: rejectInvitation,
|
||||
onDone: onRejectInvitationDone,
|
||||
onError: onRejectInvitationError,
|
||||
} = useMutation<{ rejectInvitation: IMember }, { id: string }>(
|
||||
const { mutate: rejectInvitation, onError: onRejectInvitationError } =
|
||||
useMutation<{ rejectInvitation: IMember }, { id: string }>(
|
||||
REJECT_INVITATION,
|
||||
{
|
||||
refetchQueries({ data }) {
|
||||
if (!data?.rejectInvitation) {
|
||||
console.error(data);
|
||||
alert("Error while rejecting invitation");
|
||||
return [];
|
||||
}
|
||||
|
||||
emit("reject-invitation", data?.rejectInvitation);
|
||||
|
||||
// TODO Refetching the PERSON_STATUS_GROUP query is useless for the Mygroup.vue page
|
||||
const profile = data?.rejectInvitation?.actor as IPerson;
|
||||
const group = data?.rejectInvitation?.parent as IGroup;
|
||||
@@ -96,14 +97,5 @@ const {
|
||||
}
|
||||
);
|
||||
|
||||
onRejectInvitationDone((result) => {
|
||||
if (!result.data?.rejectInvitation) {
|
||||
console.error(result);
|
||||
alert("Error while rejecting invitation");
|
||||
return;
|
||||
}
|
||||
emit("reject-invitation", result.data?.rejectInvitation);
|
||||
});
|
||||
|
||||
onRejectInvitationError((err) => onError(err as unknown as ErrorResponse));
|
||||
</script>
|
||||
|
||||
@@ -338,6 +338,9 @@ export const PERSON_STATUS_GROUP = gql`
|
||||
elements {
|
||||
id
|
||||
role
|
||||
actor {
|
||||
...ActorFragment
|
||||
}
|
||||
parent {
|
||||
...ActorFragment
|
||||
}
|
||||
|
||||
@@ -327,6 +327,8 @@
|
||||
isCurrentActorAnInvitedGroupMember && groupMember !== undefined
|
||||
"
|
||||
:invitations="[groupMember]"
|
||||
@accept-invitation="refetchGroupInformations"
|
||||
@reject-invitation="refetchGroupInformations"
|
||||
/>
|
||||
<o-notification
|
||||
class="my-2"
|
||||
@@ -688,8 +690,10 @@ const {
|
||||
} = useGroup(preferredUsername, { afterDateTime: new Date() });
|
||||
const router = useRouter();
|
||||
|
||||
const { group: discussionGroup } = useGroupDiscussionsList(preferredUsername);
|
||||
const { group: resourcesGroup } = useGroupResourcesList(preferredUsername, {
|
||||
const { group: discussionGroup, refetch: refetchGroupDiscussionsList } =
|
||||
useGroupDiscussionsList(preferredUsername);
|
||||
const { group: resourcesGroup, refetch: refetchGroupResourcesList } =
|
||||
useGroupResourcesList(preferredUsername, {
|
||||
resourcesPage: 1,
|
||||
resourcesLimit: 3,
|
||||
});
|
||||
@@ -698,9 +702,11 @@ const { t } = useI18n({ useScope: "global" });
|
||||
|
||||
const { isLongEvents } = useIsLongEvents();
|
||||
|
||||
// const { person } = usePersonStatusGroup(group);
|
||||
|
||||
const { result, subscribeToMore } = useQuery<{
|
||||
const {
|
||||
result,
|
||||
subscribeToMore,
|
||||
refetch: refetchPersonStatusGroup,
|
||||
} = useQuery<{
|
||||
person: IPerson;
|
||||
}>(
|
||||
PERSON_STATUS_GROUP,
|
||||
@@ -755,6 +761,12 @@ watch(
|
||||
}
|
||||
);
|
||||
|
||||
const refetchGroupInformations = () => {
|
||||
refetchPersonStatusGroup();
|
||||
refetchGroupResourcesList();
|
||||
refetchGroupDiscussionsList();
|
||||
};
|
||||
|
||||
const { mutate: joinGroupMutation, onError: onJoinGroupError } =
|
||||
useMutation(JOIN_GROUP);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user