Moved the connection handler

canary
WolverinDEV 2020-09-24 11:24:31 +02:00
parent 4185e8b549
commit 92dfd41e58
25 changed files with 30 additions and 35 deletions

View File

@ -15,7 +15,6 @@ import {CommandResult} from "./connection/ServerConnectionDeclaration";
import {defaultRecorder, RecorderProfile} from "./voice/RecorderProfile";
import {Frame} from "./ui/frames/chat_frame";
import {Hostbanner} from "./ui/frames/hostbanner";
import {server_connections} from "./ui/frames/connection_handlers";
import {connection_log, Regex} from "./ui/modal/ModalConnect";
import {formatMessage} from "./ui/frames/chat";
import {spawnAvatarUpload} from "./ui/modal/ModalAvatar";
@ -38,6 +37,7 @@ import {ServerFeature, ServerFeatures} from "./connection/ServerFeatures";
import {ChannelTree} from "./tree/ChannelTree";
import {LocalClientEntry} from "./tree/Client";
import {ServerAddress} from "./tree/Server";
import {server_connections} from "tc-shared/ConnectionManager";
export enum InputHardwareState {
MISSING,

View File

@ -1,10 +1,10 @@
import {ConnectionHandler, DisconnectReason} from "../../ConnectionHandler";
import {Settings, settings} from "../../settings";
import * as top_menu from "./MenuBar";
import {Registry} from "../../events";
import {ConnectionHandler, DisconnectReason} from "./ConnectionHandler";
import {Settings, settings} from "./settings";
import {Registry} from "./events";
import * as top_menu from "./ui/frames/MenuBar";
export let server_connections: ConnectionManager;
export function initialize() {
export function initializeServerConnections() {
if(server_connections) throw tr("Connection manager has already been initialized");
server_connections = new ConnectionManager($("#connection-handlers"));
}
@ -30,8 +30,9 @@ export class ConnectionManager {
this._tag = tag;
if(settings.static_global(Settings.KEY_DISABLE_MULTI_SESSION, false))
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");

View File

@ -1,9 +1,9 @@
import {server_connections} from "./ui/frames/connection_handlers";
import {EventType, KeyDescriptor, KeyEvent, KeyHook} from "./PPTListener";
import * as ppt from "tc-backend/ppt";
import {Settings, settings} from "./settings";
import * as log from "./log";
import {LogCategory} from "./log";
import {server_connections} from "tc-shared/ConnectionManager";
export interface KeyControl {
category: string;

View File

@ -3,11 +3,11 @@ import {LogCategory} from "./log";
import {guid} from "./crypto/uid";
import {createErrorModal, createInfoModal, createInputModal} from "./ui/elements/Modal";
import {defaultConnectProfile, findConnectProfile} from "./profiles/ConnectionProfile";
import {server_connections} from "./ui/frames/connection_handlers";
import {spawnConnectModal} from "./ui/modal/ModalConnect";
import * as top_menu from "./ui/frames/MenuBar";
import {control_bar_instance} from "./ui/frames/control-bar";
import {ConnectionHandler} from "./ConnectionHandler";
import {server_connections} from "tc-shared/ConnectionManager";
export const boorkmak_connect = (mark: Bookmark, new_tab?: boolean) => {
const profile = findConnectProfile(mark.connect_profile) || defaultConnectProfile();

View File

@ -15,7 +15,6 @@ import {
import {ChannelEntry} from "../tree/Channel";
import {ConnectionHandler, ConnectionState, DisconnectReason, ViewReasonId} from "../ConnectionHandler";
import {formatMessage} from "../ui/frames/chat";
import {server_connections} from "../ui/frames/connection_handlers";
import {spawnPoke} from "../ui/modal/ModalPoke";
import {AbstractCommandHandler, AbstractCommandHandlerBoss} from "../connection/AbstractCommandHandler";
import {batch_updates, BatchUpdateType, flush_batched_updates} from "../ui/react-elements/ReactComponentBase";
@ -24,6 +23,7 @@ import {renderBBCodeAsJQuery} from "../text/bbcode";
import {tr} from "../i18n/localize";
import {EventClient, EventType} from "../ui/frames/log/Definitions";
import {ErrorCode} from "../connection/ErrorCode";
import {server_connections} from "tc-shared/ConnectionManager";
export class ServerConnectionCommandBoss extends AbstractCommandHandlerBoss {
constructor(connection: AbstractServerConnection) {

View File

@ -3,7 +3,6 @@ import {IdentitifyType} from "../profiles/Identity";
import {TeaSpeakIdentity} from "../profiles/identities/TeamSpeakIdentity";
import {AbstractServerConnection} from "../connection/ConnectionBase";
import {ConnectionProfile} from "../profiles/ConnectionProfile";
import {settings} from "../settings";
import {ConnectParameters, DisconnectReason} from "../ConnectionHandler";
import {tr} from "../i18n/localize";

View File

@ -2,7 +2,6 @@ import {Registry} from "../events";
import {ClientGlobalControlEvents} from "../events/GlobalEvents";
import {Sound} from "../sound/Sounds";
import {ConnectionHandler} from "../ConnectionHandler";
import {server_connections} from "../ui/frames/connection_handlers";
import {createErrorModal, createInfoModal, createInputModal} from "../ui/elements/Modal";
import {spawnConnectModal} from "../ui/modal/ModalConnect";
import PermissionType from "../permission/PermissionType";
@ -15,6 +14,7 @@ import {spawnPermissionEditorModal} from "../ui/modal/permission/ModalPermission
import {tr} from "../i18n/localize";
import {spawnGlobalSettingsEditor} from "tc-shared/ui/modal/global-settings-editor/Controller";
import {spawnModalCssVariableEditor} from "tc-shared/ui/modal/css-editor/Controller";
import {server_connections} from "tc-shared/ConnectionManager";
/*
function initialize_sounds(event_registry: Registry<ClientGlobalControlEvents>) {

View File

@ -10,9 +10,9 @@ import {
FileTransferState, ResponseTransferTarget, TransferProvider,
TransferTargetType
} from "tc-shared/file/Transfer";
import {server_connections} from "tc-shared/ui/frames/connection_handlers";
import {tr} from "tc-shared/i18n/localize";
import {ErrorCode} from "tc-shared/connection/ErrorCode";
import {server_connections} from "tc-shared/ConnectionManager";
const icon_cache: ImageCache = new ImageCache("icons");
export interface IconManagerEvents {

View File

@ -14,7 +14,6 @@ import {
TransferTargetType
} from "../file/Transfer";
import {CommandResult} from "../connection/ServerConnectionDeclaration";
import {server_connections} from "../ui/frames/connection_handlers";
import {ClientEntry} from "../tree/Client";
import {tr} from "../i18n/localize";
import {
@ -30,6 +29,7 @@ import {
import {IPCChannel} from "../ipc/BrowserIPC";
import {ConnectionHandler} from "../ConnectionHandler";
import {ErrorCode} from "../connection/ErrorCode";
import {server_connections} from "tc-shared/ConnectionManager";
/* FIXME: Retry avatar download after some time! */

View File

@ -11,8 +11,6 @@ import {createInfoModal} from "tc-shared/ui/elements/Modal";
import * as stats from "./stats";
import * as fidentity from "./profiles/identities/TeaForumIdentity";
import {defaultRecorder, RecorderProfile, setDefaultRecorder} from "tc-shared/voice/RecorderProfile";
import * as cmanager from "tc-shared/ui/frames/connection_handlers";
import {server_connections} from "tc-shared/ui/frames/connection_handlers";
import {spawnConnectModal} from "tc-shared/ui/modal/ModalConnect";
import * as top_menu from "./ui/frames/MenuBar";
import {spawnYesNo} from "tc-shared/ui/modal/ModalYesNo";
@ -47,6 +45,7 @@ import "./update/UpdaterWeb";
import ContextMenuEvent = JQuery.ContextMenuEvent;
import {defaultConnectProfile, findConnectProfile} from "tc-shared/profiles/ConnectionProfile";
import {spawnGlobalSettingsEditor} from "tc-shared/ui/modal/global-settings-editor/Controller";
import {initializeServerConnections, server_connections} from "tc-shared/ConnectionManager";
let preventWelcomeUI = false;
async function initialize() {
@ -74,7 +73,8 @@ async function initialize_app() {
loader.critical_error(tr("Failed to setup main page!"));
return;
}
cmanager.initialize();
initializeServerConnections();
global_ev_handler.initialize(global_client_actions);
{
const bar = (
@ -200,7 +200,7 @@ function main() {
const initial_handler = server_connections.spawn_server_connection();
initial_handler.acquireInputHardware().then(() => {});
cmanager.server_connections.set_active_connection(initial_handler);
server_connections.set_active_connection(initial_handler);
/** Setup the XF forum identity **/
fidentity.update_forum();
keycontrol.initialize();

View File

@ -8,8 +8,8 @@ import {HTMLRenderer} from "tc-shared/ui/react-elements/HTMLRenderer";
import * as contextmenu from "tc-shared/ui/elements/ContextMenu";
import {spawn_context_menu} from "tc-shared/ui/elements/ContextMenu";
import {copy_to_clipboard} from "tc-shared/utils/helpers";
import {server_connections} from "tc-shared/ui/frames/connection_handlers";
import {global_client_actions} from "tc-shared/events/GlobalEvents";
import {server_connections} from "tc-shared/ConnectionManager";
const playIcon = require("./yt-play-button.svg");
const cssStyle = require("./youtube.scss");

View File

@ -10,7 +10,6 @@ import {openServerInfo} from "../ui/modal/ModalServerInfo";
import {createServerModal} from "../ui/modal/ModalServerEdit";
import {spawnIconSelect} from "../ui/modal/ModalIconSelect";
import {spawnAvatarList} from "../ui/modal/ModalAvatarList";
import {server_connections} from "../ui/frames/connection_handlers";
import {connection_log} from "../ui/modal/ModalConnect";
import * as top_menu from "../ui/frames/MenuBar";
import {control_bar_instance} from "../ui/frames/control-bar";
@ -18,6 +17,7 @@ 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 = "";

View File

View File

View File

@ -16,16 +16,14 @@ import {PermissionType} from "../../permission/PermissionType";
import {openBanList} from "../../ui/modal/ModalBanList";
import {spawnQueryManage} from "../../ui/modal/ModalQueryManage";
import {spawnQueryCreate} from "../../ui/modal/ModalQuery";
import {spawnSettingsModal} from "../../ui/modal/ModalSettings";
import {spawnAbout} from "../../ui/modal/ModalAbout";
import {server_connections} from "../../ui/frames/connection_handlers";
import * as loader from "tc-loader";
import {formatMessage} from "../../ui/frames/chat";
import {control_bar_instance} from "../../ui/frames/control-bar";
import {icon_cache_loader, IconManager, LocalIcon} from "../../file/Icons";
import {spawnPermissionEditorModal} from "../../ui/modal/permission/ModalPermissionEditor";
import {spawnModalCssVariableEditor} from "../../ui/modal/css-editor/Controller";
import {global_client_actions} from "tc-shared/events/GlobalEvents";
import {server_connections} from "tc-shared/ConnectionManager";
export interface HRItem { }

View File

@ -9,7 +9,6 @@ import {
ConnectionStateUpdateType
} from "tc-shared/ConnectionHandler";
import {Event, EventHandler, ReactEventHandler, Registry} from "tc-shared/events";
import {ConnectionManagerEvents, server_connections} from "tc-shared/ui/frames/connection_handlers";
import {Settings, settings} from "tc-shared/settings";
import {
add_server_to_bookmarks,
@ -24,6 +23,7 @@ import * as contextmenu from "tc-shared/ui/elements/ContextMenu";
import {createInputModal} from "tc-shared/ui/elements/Modal";
import {global_client_actions} from "tc-shared/events/GlobalEvents";
import {icon_cache_loader} from "tc-shared/file/Icons";
import {ConnectionManagerEvents, server_connections} from "tc-shared/ConnectionManager";
const cssStyle = require("./index.scss");
const cssButtonStyle = require("./button.scss");

View File

@ -3,13 +3,13 @@ import {Stage} from "tc-loader";
import * as log from "../../../log";
import {LogCategory} from "../../../log";
import {EventClient, EventServerAddress, EventType, TypeInfo} from "../../../ui/frames/log/Definitions";
import {server_connections} from "../../../ui/frames/connection_handlers";
import {renderBBCodeAsText} from "../../../text/bbcode";
import {format_time} from "../../../ui/frames/chat";
import {ViewReasonId} from "../../../ConnectionHandler";
import {findLogDispatcher} from "../../../ui/frames/log/DispatcherLog";
import {formatDate} from "../../../MessageFormatter";
import {Settings, settings} from "../../../settings";
import {server_connections} from "tc-shared/ConnectionManager";
export type DispatcherLog<T extends keyof TypeInfo> = (data: TypeInfo[T], handlerId: string, eventType: T) => void;

View File

@ -3,8 +3,8 @@ import {LogCategory} from "../log";
import {ChannelEntry} from "../tree/Channel";
import {ClientEntry} from "../tree/Client";
import {htmlEscape} from "../ui/frames/chat";
import {server_connections} from "../ui/frames/connection_handlers";
import {guid} from "../crypto/uid";
import {server_connections} from "tc-shared/ConnectionManager";
let mouse_coordinates: {x: number, y: number} = {x: 0, y: 0};

View File

@ -7,8 +7,8 @@ import {ConnectionProfile, defaultConnectProfile, findConnectProfile, availableC
import {KeyCode} from "../../PPTListener";
import * as i18nc from "../../i18n/country";
import {spawnSettingsModal} from "../../ui/modal/ModalSettings";
import {server_connections} from "../../ui/frames/connection_handlers";
import {icon_cache_loader, IconManager} from "../../file/Icons";
import {server_connections} from "tc-shared/ConnectionManager";
//FIXME: Move this shit out of this file!
export namespace connection_log {

View File

@ -17,7 +17,6 @@ import * as events from "tc-shared/events";
import {Registry} from "tc-shared/events";
import {spawnYesNo} from "tc-shared/ui/modal/ModalYesNo";
import * as i18nc from "tc-shared/i18n/country";
import {server_connections} from "tc-shared/ui/frames/connection_handlers";
import * as forum from "tc-shared/profiles/identities/teaspeak-forum";
import {formatMessage, set_icon_size} from "tc-shared/ui/frames/chat";
import {spawnTeamSpeakIdentityImport, spawnTeamSpeakIdentityImprove} from "tc-shared/ui/modal/ModalIdentity";
@ -29,6 +28,7 @@ import * as ReactDOM from "react-dom";
import {NotificationSettings} from "tc-shared/ui/modal/settings/Notifications";
import {initialize_audio_microphone_controller, MicrophoneSettingsEvents} from "tc-shared/ui/modal/settings/Microphone";
import {MicrophoneSettings} from "tc-shared/ui/modal/settings/MicrophoneRenderer";
import {server_connections} from "tc-shared/ConnectionManager";
export function spawnSettingsModal(default_page?: string): Modal {
let modal: Modal;

View File

@ -3,6 +3,7 @@ import {ModalGlobalSettingsEditor} from "tc-shared/ui/modal/global-settings-edit
import {Registry} from "tc-shared/events";
import {ModalGlobalSettingsEditorEvents, Setting} from "tc-shared/ui/modal/global-settings-editor/Definitions";
import {ConfigValueTypes, settings, Settings, SettingsKey} from "tc-shared/settings";
import {key} from "tc-shared/KeyControl";
export function spawnGlobalSettingsEditor() {
const events = new Registry<ModalGlobalSettingsEditorEvents>();

View File

@ -3,7 +3,6 @@ import {ConnectionHandler} from "tc-shared/ConnectionHandler";
import * as React from "react";
import {useState} from "react";
import {ContextDivider} from "tc-shared/ui/react-elements/ContextDivider";
import {server_connections} from "tc-shared/ui/frames/connection_handlers";
import {Translatable} from "tc-shared/ui/react-elements/i18n";
import {Registry} from "tc-shared/events";
import {
@ -348,9 +347,6 @@ export function spawnPermissionEditorModal(connection: ConnectionHandler, defaul
modal.show();
}
const spawn = () => spawnPermissionEditorModal(server_connections.active_connection());
(window as any).spawn_permissions = spawn;
function initializePermissionModalResultHandlers(events: Registry<PermissionModalEvents>) {
events.on("action_rename_group_result", event => {
if (event.status === "error") {

View File

@ -2,7 +2,6 @@ import {spawnReactModal} from "tc-shared/ui/react-elements/Modal";
import * as React from "react";
import {FileType} from "tc-shared/file/FileManager";
import {Registry} from "tc-shared/events";
import {server_connections} from "tc-shared/ui/frames/connection_handlers";
import {FileBrowser, NavigationBar} from "tc-shared/ui/modal/transfer/FileBrowser";
import {TransferInfo, TransferInfoEvents} from "tc-shared/ui/modal/transfer/TransferInfo";
import {initializeRemoteFileBrowserController} from "tc-shared/ui/modal/transfer/RemoteFileBrowserController";
@ -10,6 +9,7 @@ import {ChannelEntry} from "tc-shared/tree/Channel";
import {initializeTransferInfoController} from "tc-shared/ui/modal/transfer/TransferInfoController";
import {Translatable} from "tc-shared/ui/react-elements/i18n";
import {InternalModal} from "tc-shared/ui/react-elements/internal-modal/Controller";
import {server_connections} from "tc-shared/ConnectionManager";
const cssStyle = require("./ModalFileTransfer.scss");
export const channelPathPrefix = tr("Channel") + " ";

View File

@ -7,9 +7,9 @@ import {ConnectionHandler} from "../ConnectionHandler";
import {W2GPluginCmdHandler, W2GWatcher, W2GWatcherFollower} from "../video-viewer/W2GPlugin";
import {settings, Settings} from "../settings";
import {global_client_actions} from "../events/GlobalEvents";
import {server_connections} from "../ui/frames/connection_handlers";
import {createErrorModal} from "../ui/elements/Modal";
import {ModalController} from "../ui/react-elements/ModalDefinitions";
import {server_connections} from "tc-shared/ConnectionManager";
const parseWatcherId = (id: string): { clientId: number, clientUniqueId: string} => {
const [ clientIdString, clientUniqueId ] = id.split(" - ");

View File

@ -1,5 +1,5 @@
import {Settings, settings} from "tc-shared/settings";
import {server_connections} from "tc-shared/ui/frames/connection_handlers";
import {server_connections} from "tc-shared/ConnectionManager";
window.addEventListener("beforeunload", event => {
if(settings.static(Settings.KEY_DISABLE_UNLOAD_DIALOG))