diff --git a/loader/app/loader/script_loader.ts b/loader/app/loader/script_loader.ts index eb16ad31..a78fc8aa 100644 --- a/loader/app/loader/script_loader.ts +++ b/loader/app/loader/script_loader.ts @@ -33,7 +33,7 @@ function load_script_url(url: string) : Promise { const timeout_handle = setTimeout(() => { cleanup(); reject("timeout"); - }, 15 * 1000); + }, 120 * 1000); script_tag.type = "application/javascript"; script_tag.async = true; script_tag.defer = true; diff --git a/shared/js/connection/ServerFeatures.ts b/shared/js/connection/ServerFeatures.ts index a793fda9..be24b1db 100644 --- a/shared/js/connection/ServerFeatures.ts +++ b/shared/js/connection/ServerFeatures.ts @@ -29,7 +29,7 @@ export class ServerFeatures { readonly events: Registry; private readonly connection: ConnectionHandler; private readonly explicitCommandHandler: ExplicitCommandHandler; - private readonly stateChangeListener: (event: ConnectionEvents["notify_connection_state_changed"]) => void; + private readonly stateChangeListener: () => void; private featureAwait: Promise; private featureAwaitCallback: (success: boolean) => void; @@ -68,7 +68,7 @@ export class ServerFeatures { } }); - this.connection.events().on("notify_connection_state_changed", this.stateChangeListener = event => { + this.stateChangeListener = this.connection.events().on("notify_connection_state_changed", event => { if(event.newState === ConnectionState.CONNECTED) { this.connection.getServerConnection().send_command("listfeaturesupport").catch(error => { this.disableAllFeatures(); @@ -95,7 +95,7 @@ export class ServerFeatures { } destroy() { - this.connection.events().off(this.stateChangeListener); + this.stateChangeListener(); this.connection.getServerConnection()?.command_handler_boss()?.unregister_explicit_handler("notifyfeaturesupport", this.explicitCommandHandler); if(this.featureAwaitCallback) { diff --git a/shared/js/i18n/localize.ts b/shared/js/i18n/localize.ts index b47f2a4e..5d4a0aeb 100644 --- a/shared/js/i18n/localize.ts +++ b/shared/js/i18n/localize.ts @@ -49,7 +49,7 @@ export interface TranslationRepository { let translations: Translation[] = []; let translateCache: { [key:string]: string; } = {}; -export function tr(message: string, key?: string) { +export function tr(message: string, key?: string) : string { const sloppy = translateCache[message]; if(sloppy) { return sloppy; diff --git a/shared/js/ui/modal/ModalChangeVolumeNew.tsx b/shared/js/ui/modal/ModalChangeVolumeNew.tsx index 5d97536e..da04b91c 100644 --- a/shared/js/ui/modal/ModalChangeVolumeNew.tsx +++ b/shared/js/ui/modal/ModalChangeVolumeNew.tsx @@ -1,4 +1,4 @@ -import {spawnReactModal} from "tc-shared/ui/react-elements/Modal"; +import {spawnReactModal} from "tc-shared/ui/react-elements/modal"; import * as React from "react"; import {Slider} from "tc-shared/ui/react-elements/Slider"; import {Button} from "tc-shared/ui/react-elements/Button"; diff --git a/shared/js/ui/modal/ModalGroupCreate.tsx b/shared/js/ui/modal/ModalGroupCreate.tsx index f210189c..c4254181 100644 --- a/shared/js/ui/modal/ModalGroupCreate.tsx +++ b/shared/js/ui/modal/ModalGroupCreate.tsx @@ -1,4 +1,4 @@ -import {spawnReactModal} from "tc-shared/ui/react-elements/Modal"; +import {spawnReactModal} from "tc-shared/ui/react-elements/modal"; import {ConnectionHandler} from "tc-shared/ConnectionHandler"; import {Registry} from "tc-shared/events"; import {FlatInputField, Select} from "tc-shared/ui/react-elements/InputField"; diff --git a/shared/js/ui/modal/ModalGroupPermissionCopy.tsx b/shared/js/ui/modal/ModalGroupPermissionCopy.tsx index d6e07339..a18f3500 100644 --- a/shared/js/ui/modal/ModalGroupPermissionCopy.tsx +++ b/shared/js/ui/modal/ModalGroupPermissionCopy.tsx @@ -1,4 +1,4 @@ -import {spawnReactModal} from "tc-shared/ui/react-elements/Modal"; +import {spawnReactModal} from "tc-shared/ui/react-elements/modal"; import {ConnectionHandler} from "tc-shared/ConnectionHandler"; import {Registry} from "tc-shared/events"; import * as React from "react"; diff --git a/shared/js/ui/modal/ModalMusicManage.ts b/shared/js/ui/modal/ModalMusicManage.ts index 788a283a..2227567b 100644 --- a/shared/js/ui/modal/ModalMusicManage.ts +++ b/shared/js/ui/modal/ModalMusicManage.ts @@ -1,7 +1,7 @@ import {createErrorModal, createModal} from "../../ui/elements/Modal"; import {ConnectionHandler} from "../../ConnectionHandler"; import {MusicClientEntry} from "../../tree/Client"; -import {modal, Registry} from "../../events"; +import {Registry} from "../../events"; import {CommandResult} from "../../connection/ServerConnectionDeclaration"; import {LogCategory, logError, logWarn} from "../../log"; import {tr, tra} from "../../i18n/localize"; @@ -12,8 +12,160 @@ import * as htmltags from "../../ui/htmltags"; import {ErrorCode} from "../../connection/ErrorCode"; import ServerGroup = find.ServerGroup; +type BotStatusType = "name" | "description" | "volume" | "country_code" | "channel_commander" | "priority_speaker"; +type PlaylistStatusType = "replay_mode" | "finished" | "delete_played" | "max_size" | "notify_song_change"; +interface music_manage { + show_container: { container: "settings" | "permissions"; }; + + /* setting relevant */ + query_bot_status: {}, + bot_status: { + status: "success" | "error"; + error_msg?: string; + data?: { + name: string, + description: string, + volume: number, + + country_code: string, + default_country_code: string, + + channel_commander: boolean, + priority_speaker: boolean, + + client_version: string, + client_platform: string, + + uptime_mode: number, + bot_type: number + } + }, + set_bot_status: { + key: BotStatusType, + value: any + }, + set_bot_status_result: { + key: BotStatusType, + status: "success" | "error" | "timeout", + error_msg?: string, + value?: any + } + + query_playlist_status: {}, + playlist_status: { + status: "success" | "error", + error_msg?: string, + data?: { + replay_mode: number, + finished: boolean, + delete_played: boolean, + max_size: number, + notify_song_change: boolean + } + }, + set_playlist_status: { + key: PlaylistStatusType, + value: any + }, + set_playlist_status_result: { + key: PlaylistStatusType, + status: "success" | "error" | "timeout", + error_msg?: string, + value?: any + } + + /* permission relevant */ + show_client_list: {}, + hide_client_list: {}, + + filter_client_list: { filter: string | undefined }, + + "refresh_permissions": {}, + + query_special_clients: {}, + special_client_list: { + status: "success" | "error" | "error-permission", + error_msg?: string, + clients?: { + name: string, + unique_id: string, + database_id: number + }[] + }, + + search_client: { text: string }, + search_client_result: { + status: "error" | "timeout" | "empty" | "success", + error_msg?: string, + client?: { + name: string, + unique_id: string, + database_id: number + } + }, + + /* sets a client to set the permission for */ + special_client_set: { + client?: { + name: string, + unique_id: string, + database_id: number + } + }, + + "query_general_permissions": {}, + "general_permissions": { + status: "error" | "timeout" | "success", + error_msg?: string, + permissions?: {[key: string]:number} + }, + "set_general_permission_result": { + status: "error" | "success", + key: string, + value?: number, + error_msg?: string + }, + "set_general_permission": { /* try to change a permission for the server */ + key: string, + value: number + }, + + + "query_client_permissions": { client_database_id: number }, + "client_permissions": { + status: "error" | "timeout" | "success", + client_database_id: number, + error_msg?: string, + permissions?: {[key: string]:number} + }, + "set_client_permission_result": { + status: "error" | "success", + client_database_id: number, + key: string, + value?: number, + error_msg?: string + }, + "set_client_permission": { /* try to change a permission for the server */ + client_database_id: number, + key: string, + value: number + }, + + "query_group_permissions": { permission_name: string }, + "group_permissions": { + permission_name: string; + status: "error" | "timeout" | "success" + groups?: { + name: string, + value: number, + id: number + }[], + error_msg?: string + } +} + export function openMusicManage(client: ConnectionHandler, bot: MusicClientEntry) { - const ev_registry = new Registry(); + const ev_registry = new Registry(); ev_registry.enableDebug("music-manage"); //dummy_controller(ev_registry); permission_controller(ev_registry, bot, client); @@ -36,7 +188,7 @@ export function openMusicManage(client: ConnectionHandler, bot: MusicClientEntry modal.open(); } -function permission_controller(event_registry: Registry, bot: MusicClientEntry, client: ConnectionHandler) { +function permission_controller(event_registry: Registry, bot: MusicClientEntry, client: ConnectionHandler) { const error_msg = error => { if (error instanceof CommandResult) { if (error.id === ErrorCode.SERVER_INSUFFICIENT_PERMISSIONS) { @@ -380,7 +532,7 @@ function permission_controller(event_registry: Registry, bot } } -function dummy_controller(event_registry: Registry) { +function dummy_controller(event_registry: Registry) { /* settings */ { event_registry.on("query_bot_status", event => { @@ -510,7 +662,7 @@ function dummy_controller(event_registry: Registry) { } -function build_modal(event_registry: Registry): JQuery { +function build_modal(event_registry: Registry): JQuery { const tag = $("#tmpl_music_manage").renderTag(); const container_settings = tag.find(".body > .category-settings"); @@ -563,7 +715,7 @@ function build_modal(event_registry: Registry): JQuery, tag: JQuery) { +function build_settings_container(event_registry: Registry, tag: JQuery) { const show_change_error = (header, message) => { createErrorModal(tr("Failed to change value"), header + "
" + message).open(); }; @@ -1169,7 +1321,7 @@ function build_settings_container(event_registry: Registry, } } -function build_permission_container(event_registry: Registry, tag: JQuery) { +function build_permission_container(event_registry: Registry, tag: JQuery) { /* client search mechanism */ { const container = tag.find(".table-head .column-client-specific .client-select"); diff --git a/shared/js/ui/modal/channel-edit/Controller.ts b/shared/js/ui/modal/channel-edit/Controller.ts index ed666c98..402c87ca 100644 --- a/shared/js/ui/modal/channel-edit/Controller.ts +++ b/shared/js/ui/modal/channel-edit/Controller.ts @@ -10,7 +10,7 @@ import {Registry} from "tc-shared/events"; import {ChannelPropertyProviders} from "tc-shared/ui/modal/channel-edit/ControllerProperties"; import {LogCategory, logDebug, logError} from "tc-shared/log"; import {ChannelPropertyPermissionsProviders} from "tc-shared/ui/modal/channel-edit/ControllerPermissions"; -import {spawnModal} from "tc-shared/ui/react-elements/Modal"; +import {spawnModal} from "tc-shared/ui/react-elements/modal"; import {PermissionValue} from "tc-shared/permission/PermissionManager"; import {CommandResult} from "tc-shared/connection/ServerConnectionDeclaration"; import PermissionType from "tc-shared/permission/PermissionType"; diff --git a/shared/js/ui/modal/echo-test/Controller.tsx b/shared/js/ui/modal/echo-test/Controller.tsx index 3451dd8f..faeeb904 100644 --- a/shared/js/ui/modal/echo-test/Controller.tsx +++ b/shared/js/ui/modal/echo-test/Controller.tsx @@ -1,4 +1,4 @@ -import {spawnModal} from "tc-shared/ui/react-elements/Modal"; +import {spawnModal} from "tc-shared/ui/react-elements/modal"; import * as React from "react"; import {Registry} from "tc-shared/events"; import {EchoTestEvents, TestState} from "tc-shared/ui/modal/echo-test/Definitions"; diff --git a/shared/js/ui/modal/global-settings-editor/Controller.tsx b/shared/js/ui/modal/global-settings-editor/Controller.tsx index 5b5c4409..7e971c67 100644 --- a/shared/js/ui/modal/global-settings-editor/Controller.tsx +++ b/shared/js/ui/modal/global-settings-editor/Controller.tsx @@ -1,4 +1,4 @@ -import {spawnModal} from "tc-shared/ui/react-elements/Modal"; +import {spawnModal} from "tc-shared/ui/react-elements/modal"; import {Registry} from "tc-shared/events"; import {ModalGlobalSettingsEditorEvents, Setting} from "tc-shared/ui/modal/global-settings-editor/Definitions"; import {RegistryKey, RegistryValueType, Settings, settings} from "tc-shared/settings"; diff --git a/shared/js/ui/modal/global-settings-editor/Renderer.tsx b/shared/js/ui/modal/global-settings-editor/Renderer.tsx index f4c3428a..285c57ec 100644 --- a/shared/js/ui/modal/global-settings-editor/Renderer.tsx +++ b/shared/js/ui/modal/global-settings-editor/Renderer.tsx @@ -1,7 +1,6 @@ import {Translatable} from "tc-shared/ui/react-elements/i18n"; import * as React from "react"; import {createContext, useContext, useRef, useState} from "react"; -import {InternalModal} from "tc-shared/ui/react-elements/internal-modal/Controller"; import {IpcRegistryDescription, Registry} from "tc-shared/events"; import {ModalGlobalSettingsEditorEvents, Setting} from "tc-shared/ui/modal/global-settings-editor/Definitions"; import {LoadingDots} from "tc-shared/ui/react-elements/LoadingDots"; diff --git a/shared/js/ui/modal/permission/ModalPermissionEditor.tsx b/shared/js/ui/modal/permission/ModalPermissionEditor.tsx index 32501a8c..6a06f6a6 100644 --- a/shared/js/ui/modal/permission/ModalPermissionEditor.tsx +++ b/shared/js/ui/modal/permission/ModalPermissionEditor.tsx @@ -1,4 +1,4 @@ -import {spawnReactModal} from "tc-shared/ui/react-elements/Modal"; +import {spawnReactModal} from "tc-shared/ui/react-elements/modal"; import {ConnectionHandler} from "tc-shared/ConnectionHandler"; import * as React from "react"; import {useState} from "react"; diff --git a/shared/js/ui/modal/transfer/ModalFileTransfer.tsx b/shared/js/ui/modal/transfer/ModalFileTransfer.tsx index 511daa0d..da7f588b 100644 --- a/shared/js/ui/modal/transfer/ModalFileTransfer.tsx +++ b/shared/js/ui/modal/transfer/ModalFileTransfer.tsx @@ -1,4 +1,4 @@ -import {spawnReactModal} from "tc-shared/ui/react-elements/Modal"; +import {spawnReactModal} from "tc-shared/ui/react-elements/modal"; import * as React from "react"; import {Registry} from "tc-shared/events"; import {FileBrowserRenderer, NavigationBar} from "./FileBrowserRenderer"; diff --git a/shared/js/ui/modal/video-source/Controller.tsx b/shared/js/ui/modal/video-source/Controller.tsx index 1c929cf9..e640b313 100644 --- a/shared/js/ui/modal/video-source/Controller.tsx +++ b/shared/js/ui/modal/video-source/Controller.tsx @@ -1,5 +1,5 @@ import {Registry} from "tc-shared/events"; -import {spawnReactModal} from "tc-shared/ui/react-elements/Modal"; +import {spawnReactModal} from "tc-shared/ui/react-elements/modal"; import {ModalVideoSourceEvents} from "tc-shared/ui/modal/video-source/Definitions"; import {ModalVideoSource} from "tc-shared/ui/modal/video-source/Renderer"; import {getVideoDriver, VideoPermissionStatus, VideoSource} from "tc-shared/video/VideoSource"; diff --git a/shared/js/ui/modal/whats-new/Controller.tsx b/shared/js/ui/modal/whats-new/Controller.tsx index ca045a86..bca43401 100644 --- a/shared/js/ui/modal/whats-new/Controller.tsx +++ b/shared/js/ui/modal/whats-new/Controller.tsx @@ -1,4 +1,4 @@ -import {spawnReactModal} from "tc-shared/ui/react-elements/Modal"; +import {spawnReactModal} from "tc-shared/ui/react-elements/modal"; import {InternalModal} from "tc-shared/ui/react-elements/internal-modal/Controller"; import * as React from "react"; import {WhatsNew} from "tc-shared/ui/modal/whats-new/Renderer"; diff --git a/shared/js/ui/react-elements/modal/Definitions.ts b/shared/js/ui/react-elements/modal/Definitions.ts index 2e91c0bf..78b3da2c 100644 --- a/shared/js/ui/react-elements/modal/Definitions.ts +++ b/shared/js/ui/react-elements/modal/Definitions.ts @@ -7,6 +7,7 @@ import {EchoTestEvents} from "tc-shared/ui/modal/echo-test/Definitions"; import {ModalGlobalSettingsEditorEvents} from "tc-shared/ui/modal/global-settings-editor/Definitions"; export type ModalType = "error" | "warning" | "info" | "none"; +export type ModalRenderType = "page" | "dialog"; export interface ModalOptions { /** diff --git a/shared/js/ui/react-elements/modal/Renderer.tsx b/shared/js/ui/react-elements/modal/Renderer.tsx new file mode 100644 index 00000000..c963674f --- /dev/null +++ b/shared/js/ui/react-elements/modal/Renderer.tsx @@ -0,0 +1,43 @@ +import { + AbstractModal, + ModalFunctionController, + ModalOptions, + ModalRenderType +} from "tc-shared/ui/react-elements/modal/Definitions"; +import {useContext} from "react"; + +const ControllerContext = useContext(undefined); + +interface RendererControllerEvents { + +} + +export class ModalRendererController { + readonly renderType: ModalRenderType; + readonly modal: AbstractModal; + + constructor(renderType: ModalRenderType, modal: AbstractModal,) { + this.renderType = renderType; + this.modal = modal; + } + + setShown(shown: boolean) { + + } +} + +export const ModalRenderer = (props: { + mode: "page" | "dialog", + modal: AbstractModal, + modalOptions: ModalOptions, + modalActions: ModalFunctionController +}) => { + +} + +const ModalRendererDialog = (props: { + modal: AbstractModal, + modalOptions: ModalOptions, + modalActions: ModalFunctionController +}) => { +} \ No newline at end of file diff --git a/web/app/voice/VoicePlayer.ts b/web/app/voice/VoicePlayer.ts index 3ff3fd5c..2f1fec1d 100644 --- a/web/app/voice/VoicePlayer.ts +++ b/web/app/voice/VoicePlayer.ts @@ -23,6 +23,7 @@ export class VoicePlayer implements VoicePlayer { private currentRtpTrack: RemoteRTPAudioTrack; constructor() { + this.volume = 1; this.listenerTrackStateChanged = event => this.handleTrackStateChanged(event.newState); this.events = new Registry(); this.currentState = VoicePlayerState.STOPPED;