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,28 +29,33 @@ const emit = defineEmits<{
|
|||||||
(e: "reject-invitation", member: IMember): void;
|
(e: "reject-invitation", member: IMember): void;
|
||||||
}>();
|
}>();
|
||||||
|
|
||||||
const {
|
const { mutate: acceptInvitation, onError: onAcceptInvitationError } =
|
||||||
mutate: acceptInvitation,
|
useMutation<{ acceptInvitation: IMember }, { id: string }>(
|
||||||
onDone: onAcceptInvitationDone,
|
ACCEPT_INVITATION,
|
||||||
onError: onAcceptInvitationError,
|
{
|
||||||
} = useMutation<{ acceptInvitation: IMember }, { id: string }>(
|
refetchQueries({ data }) {
|
||||||
ACCEPT_INVITATION,
|
if (!data?.acceptInvitation) {
|
||||||
{
|
console.error(data);
|
||||||
refetchQueries({ data }) {
|
alert("Error while accepting invitation");
|
||||||
const profile = data?.acceptInvitation?.actor as IPerson;
|
return [];
|
||||||
const group = data?.acceptInvitation?.parent as IGroup;
|
}
|
||||||
if (profile && group) {
|
|
||||||
return [
|
emit("accept-invitation", data?.acceptInvitation);
|
||||||
{
|
|
||||||
query: PERSON_STATUS_GROUP,
|
const profile = data?.acceptInvitation?.actor as IPerson;
|
||||||
variables: { id: profile.id, group: usernameWithDomain(group) },
|
const group = data?.acceptInvitation?.parent as IGroup;
|
||||||
},
|
if (profile && group) {
|
||||||
];
|
return [
|
||||||
}
|
{
|
||||||
return [];
|
query: PERSON_STATUS_GROUP,
|
||||||
},
|
variables: { id: profile.id, group: usernameWithDomain(group) },
|
||||||
}
|
},
|
||||||
);
|
];
|
||||||
|
}
|
||||||
|
return [];
|
||||||
|
},
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
const notifier = inject<Notifier>("notifier");
|
const notifier = inject<Notifier>("notifier");
|
||||||
|
|
||||||
@@ -61,49 +66,36 @@ 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));
|
onAcceptInvitationError((err) => onError(err as unknown as ErrorResponse));
|
||||||
|
|
||||||
const {
|
const { mutate: rejectInvitation, onError: onRejectInvitationError } =
|
||||||
mutate: rejectInvitation,
|
useMutation<{ rejectInvitation: IMember }, { id: string }>(
|
||||||
onDone: onRejectInvitationDone,
|
REJECT_INVITATION,
|
||||||
onError: onRejectInvitationError,
|
{
|
||||||
} = useMutation<{ rejectInvitation: IMember }, { id: string }>(
|
refetchQueries({ data }) {
|
||||||
REJECT_INVITATION,
|
if (!data?.rejectInvitation) {
|
||||||
{
|
console.error(data);
|
||||||
refetchQueries({ data }) {
|
alert("Error while rejecting invitation");
|
||||||
// TODO Refetching the PERSON_STATUS_GROUP query is useless for the Mygroup.vue page
|
return [];
|
||||||
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 [];
|
|
||||||
},
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
onRejectInvitationDone((result) => {
|
emit("reject-invitation", data?.rejectInvitation);
|
||||||
if (!result.data?.rejectInvitation) {
|
|
||||||
console.error(result);
|
// TODO Refetching the PERSON_STATUS_GROUP query is useless for the Mygroup.vue page
|
||||||
alert("Error while rejecting invitation");
|
const profile = data?.rejectInvitation?.actor as IPerson;
|
||||||
return;
|
const group = data?.rejectInvitation?.parent as IGroup;
|
||||||
}
|
if (profile && group) {
|
||||||
emit("reject-invitation", result.data?.rejectInvitation);
|
return [
|
||||||
});
|
{
|
||||||
|
query: PERSON_STATUS_GROUP,
|
||||||
|
variables: { id: profile.id, group: usernameWithDomain(group) },
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
|
return [];
|
||||||
|
},
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
onRejectInvitationError((err) => onError(err as unknown as ErrorResponse));
|
onRejectInvitationError((err) => onError(err as unknown as ErrorResponse));
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -338,6 +338,9 @@ export const PERSON_STATUS_GROUP = gql`
|
|||||||
elements {
|
elements {
|
||||||
id
|
id
|
||||||
role
|
role
|
||||||
|
actor {
|
||||||
|
...ActorFragment
|
||||||
|
}
|
||||||
parent {
|
parent {
|
||||||
...ActorFragment
|
...ActorFragment
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -327,6 +327,8 @@
|
|||||||
isCurrentActorAnInvitedGroupMember && groupMember !== undefined
|
isCurrentActorAnInvitedGroupMember && groupMember !== undefined
|
||||||
"
|
"
|
||||||
:invitations="[groupMember]"
|
:invitations="[groupMember]"
|
||||||
|
@accept-invitation="refetchGroupInformations"
|
||||||
|
@reject-invitation="refetchGroupInformations"
|
||||||
/>
|
/>
|
||||||
<o-notification
|
<o-notification
|
||||||
class="my-2"
|
class="my-2"
|
||||||
@@ -688,19 +690,23 @@ const {
|
|||||||
} = useGroup(preferredUsername, { afterDateTime: new Date() });
|
} = useGroup(preferredUsername, { afterDateTime: new Date() });
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
|
||||||
const { group: discussionGroup } = useGroupDiscussionsList(preferredUsername);
|
const { group: discussionGroup, refetch: refetchGroupDiscussionsList } =
|
||||||
const { group: resourcesGroup } = useGroupResourcesList(preferredUsername, {
|
useGroupDiscussionsList(preferredUsername);
|
||||||
resourcesPage: 1,
|
const { group: resourcesGroup, refetch: refetchGroupResourcesList } =
|
||||||
resourcesLimit: 3,
|
useGroupResourcesList(preferredUsername, {
|
||||||
});
|
resourcesPage: 1,
|
||||||
|
resourcesLimit: 3,
|
||||||
|
});
|
||||||
|
|
||||||
const { t } = useI18n({ useScope: "global" });
|
const { t } = useI18n({ useScope: "global" });
|
||||||
|
|
||||||
const { isLongEvents } = useIsLongEvents();
|
const { isLongEvents } = useIsLongEvents();
|
||||||
|
|
||||||
// const { person } = usePersonStatusGroup(group);
|
const {
|
||||||
|
result,
|
||||||
const { result, subscribeToMore } = useQuery<{
|
subscribeToMore,
|
||||||
|
refetch: refetchPersonStatusGroup,
|
||||||
|
} = useQuery<{
|
||||||
person: IPerson;
|
person: IPerson;
|
||||||
}>(
|
}>(
|
||||||
PERSON_STATUS_GROUP,
|
PERSON_STATUS_GROUP,
|
||||||
@@ -755,6 +761,12 @@ watch(
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const refetchGroupInformations = () => {
|
||||||
|
refetchPersonStatusGroup();
|
||||||
|
refetchGroupResourcesList();
|
||||||
|
refetchGroupDiscussionsList();
|
||||||
|
};
|
||||||
|
|
||||||
const { mutate: joinGroupMutation, onError: onJoinGroupError } =
|
const { mutate: joinGroupMutation, onError: onJoinGroupError } =
|
||||||
useMutation(JOIN_GROUP);
|
useMutation(JOIN_GROUP);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user