diff --git a/js/src/views/Group/Group.vue b/js/src/views/Group/Group.vue
index 30d5de094..b18cbf078 100644
--- a/js/src/views/Group/Group.vue
+++ b/js/src/views/Group/Group.vue
@@ -102,8 +102,18 @@
@click="isReportModalActive = true"
>
- {{ $t("Report") }}
+ {{ $t("Report") }}
+
+
+
+
+
+ {{ $t("Leave") }}
@@ -112,8 +122,8 @@
:href="`@${preferredUsername}/feed/atom`"
:title="$t('Atom feed for events and posts')"
>
- {{ $t("RSS/Atom Feed") }}
+ {{ $t("RSS/Atom Feed") }}
@@ -121,8 +131,8 @@
:href="`@${preferredUsername}/feed/ics`"
:title="$t('ICS feed for events')"
>
- {{ $t("ICS/WebCal Feed") }}
+ {{ $t("ICS/WebCal Feed") }}
@@ -222,8 +232,8 @@
@click="isReportModalActive = true"
>
- {{ $t("Report") }}
+ {{ $t("Report") }}
@@ -232,8 +242,8 @@
:href="`@${preferredUsername}/feed/atom`"
:title="$t('Atom feed for events and posts')"
>
- {{ $t("RSS/Atom Feed") }}
+ {{ $t("RSS/Atom Feed") }}
@@ -241,8 +251,8 @@
:href="`@${preferredUsername}/feed/ics`"
:title="$t('ICS feed for events')"
>
- {{ $t("ICS/WebCal Feed") }}
+ {{ $t("ICS/WebCal Feed") }}
@@ -546,6 +556,7 @@ import RouteName from "../../router/name";
import GroupSection from "../../components/Group/GroupSection.vue";
import ReportModal from "../../components/Report/ReportModal.vue";
import { PERSON_MEMBERSHIP_GROUP } from "@/graphql/actor";
+import { LEAVE_GROUP } from "@/graphql/group";
@Component({
apollo: {
@@ -625,6 +636,34 @@ export default class Group extends mixins(GroupMixin) {
});
}
+ async leaveGroup(): Promise {
+ try {
+ const [group, currentActorId] = [
+ usernameWithDomain(this.group),
+ this.currentActor.id,
+ ];
+ await this.$apollo.mutate({
+ mutation: LEAVE_GROUP,
+ variables: {
+ groupId: this.group.id,
+ },
+ refetchQueries: [
+ {
+ query: PERSON_MEMBERSHIP_GROUP,
+ variables: {
+ id: currentActorId,
+ group,
+ },
+ },
+ ],
+ });
+ } catch (error) {
+ if (error.graphQLErrors && error.graphQLErrors.length > 0) {
+ this.$notifier.error(error.graphQLErrors[0].message);
+ }
+ }
+ }
+
acceptInvitation(): void {
if (this.groupMember) {
const index = this.person.memberships.elements.findIndex(
diff --git a/js/src/views/Group/MyGroups.vue b/js/src/views/Group/MyGroups.vue
index e7c80102f..2ae851f77 100644
--- a/js/src/views/Group/MyGroups.vue
+++ b/js/src/views/Group/MyGroups.vue
@@ -139,22 +139,28 @@ export default class MyGroups extends Vue {
}
async leaveGroup(group: IGroup): Promise {
- const { page, limit } = this;
- await this.$apollo.mutate({
- mutation: LEAVE_GROUP,
- variables: {
- groupId: group.id,
- },
- refetchQueries: [
- {
- query: LOGGED_USER_MEMBERSHIPS,
- variables: {
- page,
- limit,
- },
+ try {
+ const { page, limit } = this;
+ await this.$apollo.mutate({
+ mutation: LEAVE_GROUP,
+ variables: {
+ groupId: group.id,
},
- ],
- });
+ refetchQueries: [
+ {
+ query: LOGGED_USER_MEMBERSHIPS,
+ variables: {
+ page,
+ limit,
+ },
+ },
+ ],
+ });
+ } catch (error) {
+ if (error.graphQLErrors && error.graphQLErrors.length > 0) {
+ this.$notifier.error(error.graphQLErrors[0].message);
+ }
+ }
}
get invitations(): IMember[] {