Removed old connection handler code

canary
WolverinDEV 2020-09-25 18:29:42 +02:00
parent 35b35d4db6
commit 72289dee12
4 changed files with 4 additions and 99 deletions

View File

@ -212,25 +212,6 @@ export class ConnectionHandler {
this.groups = new GroupManager(this);
this._local_client = new LocalClientEntry(this);
/* initialize connection handler tab entry */
{
this.tag_connection_handler = $.spawn("div").addClass("connection-container");
$.spawn("div").addClass("server-icon icon client-server_green").appendTo(this.tag_connection_handler);
$.spawn("div").addClass("server-name").appendTo(this.tag_connection_handler);
$.spawn("div").addClass("button-close icon client-tab_close_button").appendTo(this.tag_connection_handler);
this.tag_connection_handler.on('click', event => {
if(event.isDefaultPrevented())
return;
server_connections.set_active_connection(this);
});
this.tag_connection_handler.find(".button-close").on('click', event => {
server_connections.destroy_server_connection(this);
event.preventDefault();
});
this.tab_set_name(tr("Not connected"));
}
this.event_registry.register_handler(this);
this.events().fire("notify_handler_initialized");
@ -251,16 +232,10 @@ export class ConnectionHandler {
return this.event_registry;
}
tab_set_name(name: string) {
this.tag_connection_handler.toggleClass('cutoff-name', name.length > 30);
this.tag_connection_handler.find(".server-name").text(name);
}
async startConnection(addr: string, profile: ConnectionProfile, user_action: boolean, parameters: ConnectParameters) {
this.cancel_reconnect(false);
this._reconnect_attempt = parameters.auto_reconnect_attempt || false;
this.handleDisconnect(DisconnectReason.REQUESTED);
this.tab_set_name(tr("Connecting"));
let server_address: ServerAddress = {
host: "",
@ -470,7 +445,6 @@ export class ConnectionHandler {
handleDisconnect(type: DisconnectReason, data: any = {}) {
this._connect_initialize_id++;
this.tab_set_name(tr("Not connected"));
let auto_reconnect = false;
switch (type) {
case DisconnectReason.REQUESTED:
@ -1014,9 +988,6 @@ export class ConnectionHandler {
this.event_registry.unregister_handler(this);
this.cancel_reconnect(true);
this.tag_connection_handler?.remove();
this.tag_connection_handler = undefined;
this.hostbanner?.destroy();
this.hostbanner = undefined;

View File

@ -1,5 +1,4 @@
import {ConnectionHandler, DisconnectReason} from "./ConnectionHandler";
import {Settings, settings} from "./settings";
import {Registry} from "./events";
import * as top_menu from "./ui/frames/MenuBar";
import * as loader from "tc-loader";
@ -17,30 +16,10 @@ export class ConnectionManager {
private _container_hostbanner: JQuery;
private _container_chat: JQuery;
private _tag: JQuery;
private _tag_connection_entries: JQuery;
private _tag_buttons_scoll: JQuery;
private _tag_button_scoll_right: JQuery;
private _tag_button_scoll_left: JQuery;
constructor(tag: JQuery) {
constructor() {
this.event_registry = new Registry<ConnectionManagerEvents>();
this.event_registry.enableDebug("connection-manager");
this._tag = tag;
if(settings.static_global(Settings.KEY_DISABLE_MULTI_SESSION, false)) {
this._tag.hide();
}
this._tag_connection_entries = this._tag.find(".connection-handlers");
this._tag_buttons_scoll = this._tag.find(".container-scroll");
this._tag_button_scoll_left = this._tag_buttons_scoll.find(".button-scroll-left");
this._tag_button_scoll_right = this._tag_buttons_scoll.find(".button-scroll-right");
this._tag_button_scoll_left.on('click', this._button_scroll_left_clicked.bind(this));
this._tag_button_scoll_right.on('click', this._button_scroll_right_clicked.bind(this));
this._container_log_server = $("#server-log");
this._container_channel_tree = $("#channelTree");
this._container_hostbanner = $("#hostbanner");
@ -58,10 +37,6 @@ export class ConnectionManager {
handler.initialize_client_state(this.active_handler);
this.connection_handlers.push(handler);
handler.tag_connection_handler.appendTo(this._tag_connection_entries);
this._tag.toggleClass("shown", this.connection_handlers.length > 1);
this._update_scroll();
this.event_registry.fire("notify_handler_created", { handler: handler, handlerId: handler.handlerId });
return handler;
}
@ -73,10 +48,6 @@ export class ConnectionManager {
if(!this.connection_handlers.remove(handler))
throw "unknown connection handler";
handler.tag_connection_handler.remove();
this._update_scroll();
this._tag.toggleClass("shown", this.connection_handlers.length > 1);
if(handler.serverConnection) {
const connected = handler.connected;
handler.serverConnection.disconnect("handler destroyed");
@ -100,15 +71,12 @@ export class ConnectionManager {
}
private set_active_connection_(handler: ConnectionHandler) {
this._tag_connection_entries.find(".active").removeClass("active");
this._container_channel_tree.children().detach();
this._container_chat.children().detach();
this._container_log_server.children().detach();
this._container_hostbanner.children().detach();
if(handler) {
handler.tag_connection_handler.addClass("active");
this._container_hostbanner.append(handler.hostbanner.html_tag);
this._container_channel_tree.append(handler.channelTree.tag_tree());
this._container_chat.append(handler.side_bar.html_tag());
@ -140,37 +108,6 @@ export class ConnectionManager {
all_connections() : ConnectionHandler[] {
return this.connection_handlers;
}
update_ui() {
this._update_scroll();
}
private _update_scroll() {
const has_scroll = this._tag_connection_entries.hasScrollBar("width")
&& this._tag_connection_entries.width() + 10 >= this._tag_connection_entries.parent().width();
this._tag_buttons_scoll.toggleClass("enabled", has_scroll);
this._tag.toggleClass("scrollbar", has_scroll);
if(has_scroll)
this._update_scroll_buttons();
}
private _button_scroll_right_clicked() {
this._tag_connection_entries.scrollLeft((this._tag_connection_entries.scrollLeft() || 0) + 50);
this._update_scroll_buttons();
}
private _button_scroll_left_clicked() {
this._tag_connection_entries.scrollLeft((this._tag_connection_entries.scrollLeft() || 0) - 50);
this._update_scroll_buttons();
}
private _update_scroll_buttons() {
const scroll = this._tag_connection_entries.scrollLeft() || 0;
this._tag_button_scoll_left.toggleClass("disabled", scroll <= 0);
this._tag_button_scoll_right.toggleClass("disabled", scroll + this._tag_connection_entries.width() + 2 >= this._tag_connection_entries[0].scrollWidth);
}
}
export interface ConnectionManagerEvents {
@ -199,7 +136,7 @@ export interface ConnectionManagerEvents {
loader.register_task(Stage.JAVASCRIPT_INITIALIZING, {
name: "server manager init",
function: async () => {
server_connections = new ConnectionManager($("#connection-handlers"));
server_connections = new ConnectionManager();
},
priority: 80
});

View File

@ -17,7 +17,6 @@ import { ServerEntry as ServerEntryView } from "../ui/tree/Server";
import * as React from "react";
import {Registry} from "../events";
import {ChannelTreeEntry, ChannelTreeEntryEvents} from "./ChannelTreeEntry";
import {server_connections} from "tc-shared/ConnectionManager";
export class ServerProperties {
virtualserver_host: string = "";
@ -291,10 +290,7 @@ export class ServerEntry extends ChannelTreeEntry<ServerEvents> {
for(let variable of variables) {
JSON.map_field_to(this.properties, variable.value, variable.key);
if(variable.key == "virtualserver_name") {
this.channelTree.client.tag_connection_handler.find(".server-name").text(variable.value);
server_connections.update_ui();
} else if(variable.key == "virtualserver_icon_id") {
if(variable.key == "virtualserver_icon_id") {
/* For more detail lookup client::updateVariables and client_icon_id!
* ATTENTION: This is required!
*/

View File

@ -232,6 +232,7 @@ export const ConnectionHandlerList = (props: { events: Registry<ConnectionListUI
container.scrollLeft = scrollLeft;
updateScrollButtons(scrollLeft);
}, true, [scrollShown]);
return (
<Events.Provider value={props.events}>
<div className={cssStyle.container + " " + (shown ? cssStyle.shown : "") + " " + (scrollShown ? cssStyle.scrollShown : "")} ref={refContainer}>