From cb35d79fe299506538523d094083de64796935e6 Mon Sep 17 00:00:00 2001 From: Max Date: Mon, 27 Jan 2020 09:08:31 +0100 Subject: [PATCH] Fix add/delete admins --- src/app/components/group/group.component.ts | 8 ++++++-- src/app/services/group/group.service.ts | 7 +++++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/app/components/group/group.component.ts b/src/app/components/group/group.component.ts index d9ef4d7..e639a62 100644 --- a/src/app/components/group/group.component.ts +++ b/src/app/components/group/group.component.ts @@ -209,11 +209,15 @@ export class GroupComponent implements OnInit { } addGroupAdmin(user: User) { - this.groupService.addGroupAdmin(user.userID.toString(), this.id).subscribe(); + this.groupService.addGroupAdmin(user.userID.toString(), this.id).subscribe(response => { + user.isGroupAdmin = true; + }); } removeGroupAdmin(user: User) { - this.groupService.removeGroupAdmin(user.userID.toString(), this.id).subscribe(); + this.groupService.removeGroupAdmin(user.userID.toString(), this.id).subscribe(response => { + user.isGroupAdmin = false; + }); } openPfpLightbox() { diff --git a/src/app/services/group/group.service.ts b/src/app/services/group/group.service.ts index 9e57aaf..6b96b6c 100644 --- a/src/app/services/group/group.service.ts +++ b/src/app/services/group/group.service.ts @@ -98,7 +98,7 @@ export class GroupService extends BaseService { return this.postGraphql(body, null, 0) .pipe(tap(response => { const group = this.group.getValue(); - group.updateAdmins(response.data.addGroupAdmin); + group.updateAdmins(response.data.addGroupAdmin.admins); this.group.next(group); })); } @@ -114,10 +114,13 @@ export class GroupService extends BaseService { groupId } }; + const group = this.group.getValue(); + group.admins = []; + this.group.next(group); return this.postGraphql(body, null, 0) .pipe(tap(response => { const group = this.group.getValue(); - group.updateAdmins(response.data.removeGroupAdmin); + group.updateAdmins(response.data.removeGroupAdmin.admins); this.group.next(group); })); }