From ca875258b41efe84819cd9d99f0eda3e0dba7e5c Mon Sep 17 00:00:00 2001 From: WolverinDEV Date: Fri, 25 Sep 2020 20:54:26 +0200 Subject: [PATCH] Implementing a method for switching the server connection handler order --- shared/js/ConnectionManager.ts | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/shared/js/ConnectionManager.ts b/shared/js/ConnectionManager.ts index 66a5db0e..6c0cd2bf 100644 --- a/shared/js/ConnectionManager.ts +++ b/shared/js/ConnectionManager.ts @@ -70,6 +70,20 @@ export class ConnectionManager { this.set_active_connection_(handler); } + swapHandlerOrder(handlerA: ConnectionHandler, handlerB: ConnectionHandler) { + const indexA = this.connection_handlers.findIndex(handler => handlerA === handler); + const indexB = this.connection_handlers.findIndex(handler => handlerB === handler); + + if(indexA === -1 || indexB === -1 || indexA === indexB) { + return; + } + + let temp = this.connection_handlers[indexA]; + this.connection_handlers[indexA] = this.connection_handlers[indexB]; + this.connection_handlers[indexB] = temp; + this.events().fire("notify_handler_order_changed"); + } + private set_active_connection_(handler: ConnectionHandler) { this._container_channel_tree.children().detach(); this._container_chat.children().detach(); @@ -130,7 +144,9 @@ export interface ConnectionManagerEvents { notify_handler_deleted: { handlerId: string, handler: ConnectionHandler - } + }, + + notify_handler_order_changed: { } } loader.register_task(Stage.JAVASCRIPT_INITIALIZING, {