From 9d8c3600e1743b2a8d75691d182a7d21266cd7c9 Mon Sep 17 00:00:00 2001 From: WolverinDEV Date: Sun, 21 Mar 2021 16:55:54 +0100 Subject: [PATCH] Fixed the infinity loading screen when altering groups --- .../ui/modal/group-assignment/Controller.ts | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/shared/js/ui/modal/group-assignment/Controller.ts b/shared/js/ui/modal/group-assignment/Controller.ts index af2d0134..5f41566c 100644 --- a/shared/js/ui/modal/group-assignment/Controller.ts +++ b/shared/js/ui/modal/group-assignment/Controller.ts @@ -158,7 +158,6 @@ class Controller { try { await this.handler.serverConnection.send_command(command, { sgid: groupId, cldbid: this.clientDatabaseId }); assignedGroups.groups.toggle(groupId, newValue); - this.variables.sendVariable("assignedGroupStatus"); } catch (error) { if(error instanceof CommandResult) { if(error.id === ErrorCode.SERVER_INSUFFICIENT_PERMISSIONS) { @@ -191,8 +190,8 @@ class Controller { } return true; - })); - + }).then(() => this.variables.sendVariable("assignedGroupStatus"))); + let updateMode: "none" | "status" | "refresh" = "none"; this.events.on("action_remove_all", () => { this.assignedGroups.execute(async value => { let args = []; @@ -230,25 +229,26 @@ class Controller { return; } else { /* Server does not send a bulked response. We've to do a full refresh */ - this.events.fire("action_refresh", { slowMode: false }); + updateMode = "refresh"; } } else { - let statusUpdated = false; for(let index = 0; index < args.length; index++) { if(!bulks[index].success) { continue; } - statusUpdated = true; + updateMode = "status"; value.groups.remove(args[index].sgid); } - - if(statusUpdated) { - this.variables.sendVariable("assignedGroupStatus"); - this.sendAllGroupStatus(); - } } - }).then(undefined); + }).then(() => { + if(updateMode === "status") { + this.variables.sendVariable("assignedGroupStatus"); + this.sendAllGroupStatus(); + } else if(updateMode === "refresh") { + this.events.fire("action_refresh", { slowMode: false }); + } + }); }); this.events.on("action_refresh", event => {