Fixed the infinity loading screen when altering groups

This commit is contained in:
WolverinDEV 2021-03-21 16:55:54 +01:00
parent 582b93852b
commit 9d8c3600e1

View file

@ -158,7 +158,6 @@ class Controller {
try { try {
await this.handler.serverConnection.send_command(command, { sgid: groupId, cldbid: this.clientDatabaseId }); await this.handler.serverConnection.send_command(command, { sgid: groupId, cldbid: this.clientDatabaseId });
assignedGroups.groups.toggle(groupId, newValue); assignedGroups.groups.toggle(groupId, newValue);
this.variables.sendVariable("assignedGroupStatus");
} catch (error) { } catch (error) {
if(error instanceof CommandResult) { if(error instanceof CommandResult) {
if(error.id === ErrorCode.SERVER_INSUFFICIENT_PERMISSIONS) { if(error.id === ErrorCode.SERVER_INSUFFICIENT_PERMISSIONS) {
@ -191,8 +190,8 @@ class Controller {
} }
return true; return true;
})); }).then(() => this.variables.sendVariable("assignedGroupStatus")));
let updateMode: "none" | "status" | "refresh" = "none";
this.events.on("action_remove_all", () => { this.events.on("action_remove_all", () => {
this.assignedGroups.execute(async value => { this.assignedGroups.execute(async value => {
let args = []; let args = [];
@ -230,25 +229,26 @@ class Controller {
return; return;
} else { } else {
/* Server does not send a bulked response. We've to do a full refresh */ /* Server does not send a bulked response. We've to do a full refresh */
this.events.fire("action_refresh", { slowMode: false }); updateMode = "refresh";
} }
} else { } else {
let statusUpdated = false;
for(let index = 0; index < args.length; index++) { for(let index = 0; index < args.length; index++) {
if(!bulks[index].success) { if(!bulks[index].success) {
continue; continue;
} }
statusUpdated = true; updateMode = "status";
value.groups.remove(args[index].sgid); value.groups.remove(args[index].sgid);
} }
}
if(statusUpdated) { }).then(() => {
if(updateMode === "status") {
this.variables.sendVariable("assignedGroupStatus"); this.variables.sendVariable("assignedGroupStatus");
this.sendAllGroupStatus(); this.sendAllGroupStatus();
} else if(updateMode === "refresh") {
this.events.fire("action_refresh", { slowMode: false });
} }
} });
}).then(undefined);
}); });
this.events.on("action_refresh", event => { this.events.on("action_refresh", event => {