Reworked the settings module

master
WolverinDEV 2021-01-10 16:13:15 +01:00
parent bd3810fb49
commit 71d049302c
65 changed files with 725 additions and 720 deletions

View File

@ -248,13 +248,13 @@ export class ConnectionHandler {
}
initialize_client_state(source?: ConnectionHandler) {
this.client_status.input_muted = source ? source.client_status.input_muted : settings.global(Settings.KEY_CLIENT_STATE_MICROPHONE_MUTED);
this.client_status.output_muted = source ? source.client_status.output_muted : settings.global(Settings.KEY_CLIENT_STATE_SPEAKER_MUTED);
this.client_status.input_muted = source ? source.client_status.input_muted : settings.getValue(Settings.KEY_CLIENT_STATE_MICROPHONE_MUTED);
this.client_status.output_muted = source ? source.client_status.output_muted : settings.getValue(Settings.KEY_CLIENT_STATE_SPEAKER_MUTED);
this.update_voice_status();
this.setSubscribeToAllChannels(source ? source.client_status.channel_subscribe_all : settings.global(Settings.KEY_CLIENT_STATE_SUBSCRIBE_ALL_CHANNELS));
this.doSetAway(source ? source.client_status.away : (settings.global(Settings.KEY_CLIENT_STATE_AWAY) ? settings.global(Settings.KEY_CLIENT_AWAY_MESSAGE) : false), false);
this.setQueriesShown(source ? source.client_status.queries_visible : settings.global(Settings.KEY_CLIENT_STATE_QUERY_SHOWN));
this.setSubscribeToAllChannels(source ? source.client_status.channel_subscribe_all : settings.getValue(Settings.KEY_CLIENT_STATE_SUBSCRIBE_ALL_CHANNELS));
this.doSetAway(source ? source.client_status.away : (settings.getValue(Settings.KEY_CLIENT_STATE_AWAY) ? settings.getValue(Settings.KEY_CLIENT_AWAY_MESSAGE) : false), false);
this.setQueriesShown(source ? source.client_status.queries_visible : settings.getValue(Settings.KEY_CLIENT_STATE_QUERY_SHOWN));
}
events() : Registry<ConnectionEvents> {
@ -457,7 +457,7 @@ export class ConnectionHandler {
control_bar.apply_server_voice_state();
*/
if(__build.target === "web" && settings.static_global(Settings.KEY_VOICE_ECHO_TEST_ENABLED)) {
if(__build.target === "web" && settings.getValue(Settings.KEY_VOICE_ECHO_TEST_ENABLED)) {
this.serverFeatures.awaitFeatures().then(result => {
if(!result) {
return;

View File

@ -135,7 +135,7 @@ let config: Config;
export function initialize() {
let cfg: Config;
try {
cfg = JSON.parse(settings.global(Settings.KEY_KEYCONTROL_DATA));
cfg = JSON.parse(settings.getValue(Settings.KEY_KEYCONTROL_DATA));
} catch (e) {
log.error(LogCategory.GENERAL, tr("Failed to parse old key control data."));
cfg = {};
@ -163,7 +163,7 @@ export function initialize() {
}
function save_config() {
settings.changeGlobal(Settings.KEY_KEYCONTROL_DATA, JSON.stringify(config));
settings.setValue(Settings.KEY_KEYCONTROL_DATA, JSON.stringify(config));
}
function bind_key(action: string, key: KeyDescriptor) {

View File

@ -175,7 +175,7 @@ loader.register_task(Stage.JAVASCRIPT_INITIALIZING, {
function: async () => {
const backend = getRecorderBackend();
if(backend.isRnNoiseSupported()) {
getRecorderBackend().toggleRnNoise(settings.static_global(Settings.KEY_RNNOISE_FILTER));
getRecorderBackend().toggleRnNoise(settings.getValue(Settings.KEY_RNNOISE_FILTER));
settings.globalChangeListener(Settings.KEY_RNNOISE_FILTER, value => getRecorderBackend().toggleRnNoise(value));
}
}

View File

@ -365,7 +365,7 @@ export class RtpVideoConnection implements VideoConnection {
client.setBroadcastId("camera", undefined);
});
if(settings.static_global(Settings.KEY_STOP_VIDEO_ON_SWITCH)) {
if(settings.getValue(Settings.KEY_STOP_VIDEO_ON_SWITCH)) {
Object.values(this.broadcasts).forEach(broadcast => broadcast.stopBroadcasting());
} else {
/* The server stops broadcasting by default, we've to reenable it */

View File

@ -15,5 +15,5 @@ export function requestWindowFocus() {
}
export function isFocusRequestEnabled(type: EventType) {
return settings.global(Settings.FN_EVENTS_FOCUS_ENABLED(type), focusDefaultStatus[type as any] || false);
return settings.getValue(Settings.FN_EVENTS_FOCUS_ENABLED(type), focusDefaultStatus[type as any] || false);
}

View File

@ -42,7 +42,7 @@ export function getRegisteredNotificationDispatchers() : TypeInfo[] {
}
export function isNotificationEnabled(type: EventType) {
return settings.global(Settings.FN_EVENTS_NOTIFICATION_ENABLED(type), notificationDefaultStatus[type as any] || false);
return settings.getValue(Settings.FN_EVENTS_NOTIFICATION_ENABLED(type), notificationDefaultStatus[type as any] || false);
}
const kDefaultIcon = "img/teaspeak_cup_animated.png";

View File

@ -31,7 +31,7 @@ export class ServerEventLog {
uniqueId: "log-" + Date.now() + "-" + (++uniqueLogEventId)
};
if(settings.global(Settings.FN_EVENTS_LOG_ENABLED(type), true)) {
if(settings.getValue(Settings.FN_EVENTS_LOG_ENABLED(type), true)) {
this.eventLog.push(event);
while(this.eventLog.length > this.maxHistoryLength) {
this.eventLog.pop_front();

View File

@ -42,7 +42,7 @@ export class ChannelConversation extends AbstractChat<ChannelConversationEvents>
this.conversationId = id;
this.preventUnreadUpdate = true;
const unreadTimestamp = handle.connection.settings.server(Settings.FN_CHANNEL_CHAT_READ(id), Date.now());
const unreadTimestamp = handle.connection.settings.getValue(Settings.FN_CHANNEL_CHAT_READ(id), Date.now());
this.setUnreadTimestamp(unreadTimestamp);
this.preventUnreadUpdate = false;
@ -292,7 +292,7 @@ export class ChannelConversation extends AbstractChat<ChannelConversationEvents>
return;
}
this.handle.connection.settings.changeServer(Settings.FN_CHANNEL_CHAT_READ(this.conversationId), timestamp);
this.handle.connection.settings.setValue(Settings.FN_CHANNEL_CHAT_READ(this.conversationId), timestamp);
}
public setConversationMode(mode: ChannelConversationMode, logChange: boolean) {

View File

@ -9,7 +9,7 @@ import {
setGlobalAvatarManagerFactory, uniqueId2AvatarId
} from "../file/Avatars";
import {IPCChannel} from "../ipc/BrowserIPC";
import {Settings} from "../settings";
import {AppParameters} from "../settings";
import {ChannelMessage} from "../ipc/BrowserIPC";
import {guid} from "../crypto/uid";
import { tr } from "tc-shared/i18n/localize";
@ -159,7 +159,7 @@ class RemoteAvatarManagerFactory extends AbstractAvatarManagerFactory {
constructor() {
super();
this.ipcChannel = ipc.getIpcInstance().createChannel(Settings.instance.static(Settings.KEY_IPC_REMOTE_ADDRESS, "invalid"), kIPCAvatarChannel);
this.ipcChannel = ipc.getIpcInstance().createChannel(AppParameters.getValue(AppParameters.KEY_IPC_REMOTE_ADDRESS, "invalid"), kIPCAvatarChannel);
this.ipcChannel.messageHandler = this.handleIpcMessage.bind(this);
}
@ -187,7 +187,7 @@ class RemoteAvatarManagerFactory extends AbstractAvatarManagerFactory {
return typeof this.manager[handlerId] !== "undefined";
}
private handleIpcMessage(remoteId: string, broadcast: boolean, message: ChannelMessage) {
private handleIpcMessage(_remoteId: string, broadcast: boolean, message: ChannelMessage) {
if(broadcast) {
if(message.type === "notify-handler-destroyed") {
const manager = this.manager[message.data.handler];

View File

@ -3,7 +3,7 @@ import * as loader from "tc-loader";
import {Stage} from "tc-loader";
import {ChannelMessage, IPCChannel} from "tc-shared/ipc/BrowserIPC";
import * as ipc from "tc-shared/ipc/BrowserIPC";
import {Settings} from "tc-shared/settings";
import {AppParameters} from "tc-shared/settings";
import {LogCategory, logWarn} from "tc-shared/log";
class RemoteRemoteIcon extends RemoteIcon {
@ -33,7 +33,7 @@ class RemoteIconManager extends AbstractIconManager {
constructor() {
super();
this.ipcChannel = ipc.getIpcInstance().createChannel(Settings.instance.static(Settings.KEY_IPC_REMOTE_ADDRESS, "invalid"), kIPCIconChannel);
this.ipcChannel = ipc.getIpcInstance().createChannel(AppParameters.getValue(AppParameters.KEY_IPC_REMOTE_ADDRESS, "invalid"), kIPCIconChannel);
this.ipcChannel.messageHandler = this.handleIpcMessage.bind(this);
}

View File

@ -100,13 +100,13 @@ const defaultGroupMode: GroupMode = GroupMode.PREFIX;
export function initialize(defaultLogLevel: LogType) {
for(const category of Object.keys(LogCategory).map(e => parseInt(e)).filter(e => !isNaN(e))) {
const categoryName = LogCategory[category].toLowerCase();
enabled_mapping.set(category, settings.static_global(Settings.FN_LOG_ENABLED(categoryName), enabled_mapping.get(category)));
enabled_mapping.set(category, settings.getValue(Settings.FN_LOG_ENABLED(categoryName), enabled_mapping.get(category)));
}
const baseLogLevel = settings.static_global(Settings.KEY_LOG_LEVEL, defaultLogLevel);
const baseLogLevel = settings.getValue(Settings.KEY_LOG_LEVEL, defaultLogLevel);
for(const level of Object.keys(LogType).map(e => parseInt(e)).filter(e => !isNaN(e))) {
const levelName = LogType[level].toLowerCase();
level_mapping.set(level, settings.static_global(Settings.FN_LOG_LEVEL_ENABLED(levelName), level >= baseLogLevel));
level_mapping.set(level, settings.getValue(Settings.FN_LOG_LEVEL_ENABLED(levelName), level >= baseLogLevel));
}
}

View File

@ -1,6 +1,6 @@
import * as loader from "tc-loader";
import {Stage} from "tc-loader";
import {settings, Settings} from "tc-shared/settings";
import {AppParameters, settings, Settings} from "tc-shared/settings";
import * as log from "tc-shared/log";
import {LogCategory} from "tc-shared/log";
import * as bipc from "./ipc/BrowserIPC";
@ -23,7 +23,7 @@ import * as global_ev_handler from "./events/ClientGlobalControlHandler";
import {global_client_actions} from "tc-shared/events/GlobalEvents";
import {FileTransferState, TransferProvider,} from "tc-shared/file/Transfer";
import {MenuEntryType, spawn_context_menu} from "tc-shared/ui/elements/ContextMenu";
import {copy_to_clipboard} from "tc-shared/utils/helpers";
import {copyToClipboard} from "tc-shared/utils/helpers";
import {checkForUpdatedApp} from "tc-shared/update";
import {setupJSRender} from "tc-shared/ui/jsrender";
import {ConnectRequestData} from "tc-shared/ipc/ConnectHandler";
@ -81,12 +81,7 @@ async function initialize_app() {
console.warn(tr("Failed to initialize audio controller!"));
}
aplayer.on_ready(() => {
if(aplayer.set_master_volume)
aplayer.on_ready(() => aplayer.set_master_volume(settings.global(Settings.KEY_SOUND_MASTER) / 100));
else
log.warn(LogCategory.GENERAL, tr("Client does not support aplayer.set_master_volume()... May client is too old?"));
});
aplayer.on_ready(() => aplayer.set_master_volume(settings.getValue(Settings.KEY_SOUND_MASTER) / 100));
setDefaultRecorder(new RecorderProfile("default"));
defaultRecorder.initialize().catch(error => {
@ -96,7 +91,7 @@ async function initialize_app() {
sound.initialize().then(() => {
log.info(LogCategory.AUDIO, tr("Sounds initialized"));
});
sound.set_master_volume(settings.global(Settings.KEY_SOUND_MASTER_SOUNDS) / 100);
sound.set_master_volume(settings.getValue(Settings.KEY_SOUND_MASTER_SOUNDS) / 100);
try {
await ppt.initialize();
@ -116,7 +111,7 @@ export function handle_connect_request(properties: ConnectRequestData, connectio
const password_hashed = properties.password ? properties.password.hashed : false;
if(profile && profile.valid()) {
settings.changeGlobal(Settings.KEY_USER_IS_NEW, false);
settings.setValue(Settings.KEY_USER_IS_NEW, false);
if(!aplayer.initialized()) {
spawnYesNo(tra("Connect to {}", properties.address), tra("Would you like to connect to {}?", properties.address), result => {
@ -147,7 +142,7 @@ export function handle_connect_request(properties: ConnectRequestData, connectio
function main() {
/* initialize font */
{
const font = settings.static_global(Settings.KEY_FONT_SIZE);
const font = settings.getValue(Settings.KEY_FONT_SIZE);
$(document.body).css("font-size", font + "px");
settings.globalChangeListener(Settings.KEY_FONT_SIZE, value => {
$(document.body).css("font-size", value + "px");
@ -165,9 +160,7 @@ function main() {
spawn_context_menu(event.pageX, event.pageY, {
type: MenuEntryType.ENTRY,
name: tr("Copy"),
callback: () => {
copy_to_clipboard(event.target.value);
},
callback: () => copyToClipboard(event.target.value),
icon_class: "client-copy",
visible: !!event.target.value
}, {
@ -181,21 +174,20 @@ function main() {
visible: __build.target === "client",
});
}
event.preventDefault();
return;
}
if(settings.static_global(Settings.KEY_DISABLE_GLOBAL_CONTEXT_MENU)) {
if(settings.getValue(Settings.KEY_DISABLE_GLOBAL_CONTEXT_MENU)) {
event.preventDefault();
}
});
window.removeLoaderContextMenuHook();
//top_menu.initialize();
const initial_handler = server_connections.spawn_server_connection();
initial_handler.acquireInputHardware().then(() => {});
server_connections.set_active_connection(initial_handler);
const initialHandler = server_connections.spawn_server_connection();
server_connections.set_active_connection(initialHandler);
initialHandler.acquireInputHardware().then(() => {});
/** Setup the XF forum identity **/
fidentity.update_forum();
@ -206,113 +198,17 @@ function main() {
anonymize_ip_addresses: true,
volatile_collection_only: false
});
stats.register_user_count_listener(status => {
log.info(LogCategory.STATISTICS, tr("Received user count update: %o"), status);
});
server_connections.set_active_connection(server_connections.all_connections()[0]);
checkForUpdatedApp();
(window as any).test_download = async () => {
const connection = server_connections.active_connection();
const download = connection.fileManager.initializeFileDownload({
targetSupplier: async () => await TransferProvider.provider().createDownloadTarget(),
name: "HomeStudent2019Retail.img",
path: "/",
channel: 4
});
console.log("Download stated");
await download.awaitFinished();
console.log("Download finished (%s)", FileTransferState[download.transferState()]);
//console.log(await (download.target as ResponseTransferTarget).getResponse().blob());
console.log("Have buffer");
};
(window as any).test_upload = async () => {
const connection = server_connections.active_connection();
const download = connection.fileManager.initializeFileUpload({
source: async () => await TransferProvider.provider().createTextSource("Hello my lovely world...."),
name: "test-upload.txt",
path: "/",
channel: 4
});
console.log("Download stated");
await download.awaitFinished();
console.log("Download finished (%s)", FileTransferState[download.transferState()]);
//console.log(await (download.target as ResponseTransferTarget).getResponse().blob());
console.log("Have buffer");
};
/* schedule it a bit later then the main because the main function is still within the loader */
setTimeout(() => {
//(window as any).spawnVideo();
/*
Modals.createChannelModal(connection, undefined, undefined, connection.permissions, (cb, perms) => {
});
*/
// Modals.openServerInfo(connection.channelTree.server);
//Modals.createServerModal(connection.channelTree.server, properties => Promise.resolve());
//Modals.openClientInfo(connection.getClient());
//Modals.openServerInfoBandwidth(connection.channelTree.server);
//Modals.openBanList(connection);
/*
Modals.spawnBanClient(connection,[
{name: "WolverinDEV", unique_id: "XXXX"},
{name: "WolverinDEV", unique_id: "XXXX"},
{name: "WolverinDEV", unique_id: "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"},
{name: "WolverinDEV", unique_id: "YYY"}
], () => {});
*/
}, 4000);
//spawnSettingsModal("general-keymap");
//Modals.spawnKeySelect(console.log);
//Modals.spawnBookmarkModal();
/*
{
const modal = createModal({
header: tr("Test Net Graph"),
body: () => {
const canvas = $.spawn("canvas")
.css("position", "absolute")
.css({
top: 0,
bottom: 0,
right: 0,
left: 0
});
return $.spawn("div")
.css("height", "5em")
.css("width", "30em")
.css("position", "relative")
.append(canvas);
},
footer: null
});
const graph = new net.graph.Graph(modal.htmlTag.find("canvas")[0] as any);
graph.initialize();
modal.close_listener.push(() => graph.terminate());
modal.open();
}
*/
//setTimeout(() => spawnPermissionEditorModal(server_connections.active_connection()), 3000);
//setTimeout(() => spawnGroupCreate(server_connections.active_connection(), "server"), 3000);
if(settings.static_global(Settings.KEY_USER_IS_NEW) && !preventWelcomeUI) {
if(settings.getValue(Settings.KEY_USER_IS_NEW) && !preventWelcomeUI) {
const modal = openModalNewcomer();
modal.close_listener.push(() => settings.changeGlobal(Settings.KEY_USER_IS_NEW, false));
modal.close_listener.push(() => settings.setValue(Settings.KEY_USER_IS_NEW, false));
}
//spawnGlobalSettingsEditor();
//spawnVideoPopout(server_connections.active_connection(), "https://www.youtube.com/watch?v=9683D18fyvs");
}
const task_teaweb_starter: loader.Task = {
@ -325,14 +221,17 @@ const task_teaweb_starter: loader.Task = {
log.info(LogCategory.VOICE, tr("Initialize audio controller later!"));
if(!aplayer.initializeFromGesture) {
console.error(tr("Missing aplayer.initializeFromGesture"));
} else
} else {
$(document).one('click', () => aplayer.initializeFromGesture());
}
}
loader.config.abortAnimationOnFinish = settings.static_global(Settings.KEY_LOADER_ANIMATION_ABORT);
loader.config.abortAnimationOnFinish = settings.getValue(Settings.KEY_LOADER_ANIMATION_ABORT);
} catch (ex) {
console.error(ex.stack);
if(ex instanceof ReferenceError || ex instanceof TypeError)
if(ex instanceof ReferenceError || ex instanceof TypeError) {
ex = ex.name + ": " + ex.message;
}
loader.critical_error("Failed to invoke main function:<br>" + ex);
}
},
@ -342,81 +241,78 @@ const task_teaweb_starter: loader.Task = {
const task_connect_handler: loader.Task = {
name: "Connect handler",
function: async () => {
const address = settings.static(Settings.KEY_CONNECT_ADDRESS, "");
const address = AppParameters.getValue(AppParameters.KEY_CONNECT_ADDRESS, undefined);
if(typeof address === "undefined") {
loader.register_task(loader.Stage.LOADED, task_teaweb_starter);
return;
}
/* FIXME: All additional parameters! */
const connectData = {
address: address,
profile: AppParameters.getValue(AppParameters.KEY_CONNECT_PROFILE, ""),
username: AppParameters.getValue(AppParameters.KEY_CONNECT_NICKNAME, ""),
password: {
value: AppParameters.getValue(AppParameters.KEY_CONNECT_SERVER_PASSWORD, ""),
hashed: true
}
};
const chandler = bipc.getInstanceConnectHandler();
if(settings.static(Settings.KEY_FLAG_CONNECT_DEFAULT, false) && address) {
const connect_data = {
address: address,
if(chandler && AppParameters.getValue(AppParameters.KEY_CONNECT_NO_SINGLE_INSTANCE)) {
try {
await chandler.post_connect_request(connectData, () => new Promise<boolean>(resolve => {
spawnYesNo(tr("Another TeaWeb instance is already running"), tra("Another TeaWeb instance is already running.{:br:}Would you like to connect there?"), response => {
resolve(response);
}, {
closeable: false
}).open();
}));
log.info(LogCategory.CLIENT, tr("Executed connect successfully in another browser window. Closing this window"));
profile: settings.static(Settings.KEY_CONNECT_PROFILE, ""),
username: settings.static(Settings.KEY_CONNECT_USERNAME, ""),
password: {
value: settings.static(Settings.KEY_CONNECT_PASSWORD, ""),
hashed: settings.static(Settings.KEY_FLAG_CONNECT_PASSWORD, false)
}
};
if(chandler && !settings.static(Settings.KEY_CONNECT_NO_SINGLE_INSTANCE)) {
try {
await chandler.post_connect_request(connect_data, () => new Promise<boolean>(resolve => {
spawnYesNo(tr("Another TeaWeb instance is already running"), tra("Another TeaWeb instance is already running.{:br:}Would you like to connect there?"), response => {
resolve(response);
}, {
closeable: false
}).open();
}));
log.info(LogCategory.CLIENT, tr("Executed connect successfully in another browser window. Closing this window"));
const message =
"You're connecting to {0} within the other TeaWeb instance.{:br:}" +
"You could now close this page.";
createInfoModal(
tr("Connecting successfully within other instance"),
formatMessage(/* @tr-ignore */ tr(message), connect_data.address),
{
closeable: false,
footer: undefined
}
).open();
return;
} catch(error) {
log.info(LogCategory.CLIENT, tr("Failed to execute connect within other TeaWeb instance. Using this one. Error: %o"), error);
}
const message =
"You're connecting to {0} within the other TeaWeb instance.{:br:}" +
"You could now close this page.";
createInfoModal(
tr("Connecting successfully within other instance"),
formatMessage(/* @tr-ignore */ tr(message), connectData.address),
{
closeable: false,
footer: undefined
}
).open();
return;
} catch(error) {
log.info(LogCategory.CLIENT, tr("Failed to execute connect within other TeaWeb instance. Using this one. Error: %o"), error);
}
preventWelcomeUI = true;
loader.register_task(loader.Stage.LOADED, {
priority: 0,
function: async () => handle_connect_request(connect_data, server_connections.active_connection() || server_connections.spawn_server_connection()),
name: tr("default url connect")
});
}
if(chandler) {
/* no instance avail, so lets make us avail */
chandler.callback_available = data => {
return !settings.static_global(Settings.KEY_DISABLE_MULTI_SESSION);
};
if(chandler) {
/* no instance avail, so lets make us avail */
chandler.callback_available = () => {
return !settings.getValue(Settings.KEY_DISABLE_MULTI_SESSION);
};
chandler.callback_execute = data => {
preventWelcomeUI = true;
handle_connect_request(data, server_connections.spawn_server_connection());
return true;
chandler.callback_execute = data => {
preventWelcomeUI = true;
handle_connect_request(data, server_connections.spawn_server_connection());
return true;
}
}
}
preventWelcomeUI = true;
loader.register_task(loader.Stage.LOADED, {
priority: 0,
function: async () => handle_connect_request(connectData, server_connections.active_connection() || server_connections.spawn_server_connection()),
name: tr("default url connect")
});
loader.register_task(loader.Stage.LOADED, task_teaweb_starter);
},
priority: 10
};
const task_certificate_callback: loader.Task = {
name: "certificate accept tester",
function: async () => {
loader.register_task(loader.Stage.LOADED, task_connect_handler);
},
priority: 10
};
loader.register_task(loader.Stage.JAVASCRIPT_INITIALIZING, {
name: "jrendere initialize",
function: async () => {
@ -439,16 +335,19 @@ loader.register_task(loader.Stage.JAVASCRIPT_INITIALIZING, {
await initialize();
if(__build.target == "web") {
loader.register_task(loader.Stage.LOADED, task_certificate_callback);
loader.register_task(loader.Stage.LOADED, task_connect_handler);
} else {
loader.register_task(loader.Stage.LOADED, task_teaweb_starter);
}
} catch (ex) {
if(ex instanceof Error || typeof(ex.stack) !== "undefined")
if(ex instanceof Error || typeof(ex.stack) !== "undefined") {
console.error((tr || (msg => msg))("Critical error stack trace: %o"), ex.stack);
}
if(ex instanceof ReferenceError || ex instanceof TypeError)
if(ex instanceof ReferenceError || ex instanceof TypeError) {
ex = ex.name + ": " + ex.message;
}
loader.critical_error("Failed to boot app function:<br>" + ex);
}
},
@ -458,12 +357,12 @@ loader.register_task(loader.Stage.JAVASCRIPT_INITIALIZING, {
loader.register_task(loader.Stage.LOADED, {
name: "error task",
function: async () => {
if(Settings.instance.static(Settings.KEY_LOAD_DUMMY_ERROR, false)) {
loader.critical_error("The tea is cold!", "Argh, this is evil! Cold tea dosn't taste good.");
if(AppParameters.getValue(AppParameters.KEY_LOAD_DUMMY_ERROR)) {
loader.critical_error("The tea is cold!", "Argh, this is evil! Cold tea does not taste good.");
throw "The tea is cold!";
}
},
priority: 20
priority: 2000
});
loader.register_task(Stage.JAVASCRIPT_INITIALIZING,{
@ -471,7 +370,7 @@ loader.register_task(Stage.JAVASCRIPT_INITIALIZING,{
function: async () => {
try { //Initialize main template
const main = $("#tmpl_main").renderTag({
multi_session: !settings.static_global(Settings.KEY_DISABLE_MULTI_SESSION),
multi_session: !settings.getValue(Settings.KEY_DISABLE_MULTI_SESSION),
app_version: __build.version
}).dividerfy();

View File

@ -81,7 +81,7 @@ export namespace gcaptcha {
}
function api_url() {
return settings.static_global(Settings.KEY_TEAFORO_URL);
return settings.getValue(Settings.KEY_TEAFORO_URL);
}
export class Data {

File diff suppressed because it is too large Load Diff

View File

@ -157,7 +157,7 @@ export function save() {
data.overlap = overlap_sounds;
data.ignore_muted = ignore_muted;
settings.changeGlobal(Settings.KEY_SOUND_VOLUMES, JSON.stringify(data));
settings.setValue(Settings.KEY_SOUND_VOLUMES, JSON.stringify(data));
}
}
@ -173,7 +173,7 @@ export function initialize() : Promise<void> {
/* volumes */
{
const data = JSON.parse(settings.static_global(Settings.KEY_SOUND_VOLUMES, "{}"));
const data = JSON.parse(settings.getValue(Settings.KEY_SOUND_VOLUMES, "{}"));
for(const sound_key of Object.keys(Sound)) {
if(typeof(data[Sound[sound_key]]) !== "undefined")
speech_volume[Sound[sound_key]] = data[Sound[sound_key]];

View File

@ -46,7 +46,7 @@ loader.register_task(loader.Stage.JAVASCRIPT_INITIALIZING, {
rendererReact.setTextRenderer(new class extends ElementRenderer<TextElement, React.ReactNode> {
render(element: TextElement, renderer: ReactRenderer): React.ReactNode {
if(!settings.static_global(Settings.KEY_CHAT_COLORED_EMOJIES))
if(!settings.getValue(Settings.KEY_CHAT_COLORED_EMOJIES))
return element.text();
let text = element.text();

View File

@ -6,7 +6,7 @@ import {TagElement} from "vendor/xbbcode/elements";
import * as React from "react";
import {tra} from "tc-shared/i18n/localize";
import * as DOMPurify from "dompurify";
import {copy_to_clipboard} from "tc-shared/utils/helpers";
import {copyToClipboard} from "tc-shared/utils/helpers";
import {rendererReact, rendererText} from "tc-shared/text/bbcode/renderer";
import {MenuEntryType, spawn_context_menu} from "tc-shared/ui/elements/ContextMenu";
@ -87,7 +87,7 @@ loader.register_task(loader.Stage.JAVASCRIPT_INITIALIZING, {
function: async () => {
let reactId = 0;
if(!settings.static_global(Settings.KEY_CHAT_HIGHLIGHT_CODE)) {
if(!settings.getValue(Settings.KEY_CHAT_HIGHLIGHT_CODE)) {
return;
}
/* override default parser */
@ -127,7 +127,7 @@ loader.register_task(loader.Stage.JAVASCRIPT_INITIALIZING, {
onContextMenu={event => {
event.preventDefault();
spawn_context_menu(event.pageX, event.pageY, {
callback: () => copy_to_clipboard(lines.join("\n")),
callback: () => copyToClipboard(lines.join("\n")),
name: tr("Copy code"),
type: MenuEntryType.ENTRY,
icon_class: "client-copy"

View File

@ -4,7 +4,7 @@ import * as React from "react";
import * as loader from "tc-loader";
import {rendererReact, rendererText} from "tc-shared/text/bbcode/renderer";
import * as contextmenu from "tc-shared/ui/elements/ContextMenu";
import {copy_to_clipboard} from "tc-shared/utils/helpers";
import {copyToClipboard} from "tc-shared/utils/helpers";
import * as image_preview from "tc-shared/ui/frames/image_preview";
export const regexImage = /^(?:https?):(?:\/{1,3}|\\)[-a-zA-Z0-9:;,@#%&()~_?+=\/\\.]*$/g;
@ -43,7 +43,7 @@ function loadImageForElement(element: HTMLImageElement) {
type: contextmenu.MenuEntryType.ENTRY,
icon_class: "client-browse-addon-online"
}, contextmenu.Entry.HR(), {
callback: () => copy_to_clipboard(url),
callback: () => copyToClipboard(url),
name: tr("Copy image URL to clipboard"),
type: contextmenu.MenuEntryType.ENTRY,
icon_class: "client-copy"

View File

@ -1,5 +1,5 @@
import * as contextmenu from "tc-shared/ui/elements/ContextMenu";
import {copy_to_clipboard} from "tc-shared/utils/helpers";
import {copyToClipboard} from "tc-shared/utils/helpers";
import * as loader from "tc-loader";
import {ElementRenderer} from "vendor/xbbcode/renderer/base";
import {TagElement} from "vendor/xbbcode/elements";
@ -26,7 +26,7 @@ function spawnUrlContextMenu(pageX: number, pageY: number, target: string) {
type: contextmenu.MenuEntryType.ENTRY,
visible: __build.target === "client" && false // Currently not possible
}, contextmenu.Entry.HR(), {
callback: () => copy_to_clipboard(target),
callback: () => copyToClipboard(target),
name: tr("Copy URL to clipboard"),
type: contextmenu.MenuEntryType.ENTRY,
icon_class: "client-copy"

View File

@ -7,7 +7,7 @@ import {BBCodeRenderer} from "tc-shared/text/bbcode";
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 {copyToClipboard} from "tc-shared/utils/helpers";
import {global_client_actions} from "tc-shared/events/GlobalEvents";
import {server_connections} from "tc-shared/ConnectionManager";
@ -61,7 +61,7 @@ export const YoutubeRenderer = (props: { children?: React.ReactElement | React.R
type: contextmenu.MenuEntryType.ENTRY,
icon_class: "client-browse-addon-online"
}, contextmenu.Entry.HR(), {
callback: () => copy_to_clipboard(props.url),
callback: () => copyToClipboard(props.url),
name: tr("Copy video URL to clipboard"),
type: contextmenu.MenuEntryType.ENTRY,
icon_class: "client-copy"

View File

@ -69,8 +69,8 @@ function bbcodeLinkUrls(message: string, ignore: { start: number, end: number }[
}
export function preprocessChatMessageForSend(message: string) : string {
const parseMarkdown = settings.static_global(Settings.KEY_CHAT_ENABLE_MARKDOWN);
const escapeBBCodes = !settings.static_global(Settings.KEY_CHAT_ENABLE_BBCODE);
const parseMarkdown = settings.getValue(Settings.KEY_CHAT_ENABLE_MARKDOWN);
const escapeBBCodes = !settings.getValue(Settings.KEY_CHAT_ENABLE_BBCODE);
if(parseMarkdown) {
message = renderMarkdownAsBBCode(message, text => escapeBBCodes ? escapeBBCode(text) : text);
@ -78,7 +78,7 @@ export function preprocessChatMessageForSend(message: string) : string {
message = escapeBBCode(message);
}
if(settings.static_global(Settings.KEY_CHAT_TAG_URLS)) {
if(settings.getValue(Settings.KEY_CHAT_TAG_URLS)) {
const bbcodeElements = parseBBCode(message, {});
const noParseRanges: { start: number, end: number }[] = [];

View File

@ -222,8 +222,8 @@ export class ChannelEntry extends ChannelTreeEntry<ChannelEvents> {
});
});
this.collapsed = this.channelTree.client.settings.server(Settings.FN_SERVER_CHANNEL_COLLAPSED(this.channelId));
this.subscriptionMode = this.channelTree.client.settings.server(Settings.FN_SERVER_CHANNEL_SUBSCRIBE_MODE(this.channelId));
this.collapsed = this.channelTree.client.settings.getValue(Settings.FN_SERVER_CHANNEL_COLLAPSED(this.channelId));
this.subscriptionMode = this.channelTree.client.settings.getValue(Settings.FN_SERVER_CHANNEL_SUBSCRIBE_MODE(this.channelId));
this.channelDescriptionCached = false;
this.channelDescriptionCallback = [];
@ -452,7 +452,7 @@ export class ChannelEntry extends ChannelTreeEntry<ChannelEvents> {
this.channelTree.client.getChannelConversations().setSelectedConversation(conversation);
this.channelTree.client.getSideBar().showChannel();
},
visible: !settings.static_global(Settings.KEY_SWITCH_INSTANT_CHAT)
visible: !settings.getValue(Settings.KEY_SWITCH_INSTANT_CHAT)
}, {
type: contextmenu.MenuEntryType.HR,
name: ''
@ -776,7 +776,7 @@ export class ChannelEntry extends ChannelTreeEntry<ChannelEvents> {
this.collapsed = flag;
this.events.fire("notify_collapsed_state_changed", { collapsed: flag });
this.channelTree.client.settings.changeServer(Settings.FN_SERVER_CHANNEL_COLLAPSED(this.channelId), flag);
this.channelTree.client.settings.setValue(Settings.FN_SERVER_CHANNEL_COLLAPSED(this.channelId), flag);
}
isSubscribed() : boolean {
@ -803,7 +803,7 @@ export class ChannelEntry extends ChannelTreeEntry<ChannelEvents> {
}
this.subscriptionMode = mode;
this.channelTree.client.settings.changeServer(Settings.FN_SERVER_CHANNEL_SUBSCRIBE_MODE(this.channelId), mode);
this.channelTree.client.settings.setValue(Settings.FN_SERVER_CHANNEL_SUBSCRIBE_MODE(this.channelId), mode);
if(!dontSyncSubscribeMode) {
this.updateSubscribeMode().then(undefined);
}

View File

@ -171,7 +171,7 @@ export class ChannelTree {
this.events.fire("notify_selected_entry_changed", { newEntry: entry, oldEntry: oldEntry });
if(this.selectedEntry instanceof ClientEntry) {
if(settings.static_global(Settings.KEY_SWITCH_INSTANT_CLIENT)) {
if(settings.getValue(Settings.KEY_SWITCH_INSTANT_CLIENT)) {
if(this.selectedEntry instanceof MusicClientEntry) {
this.client.getSideBar().showMusicPlayer(this.selectedEntry);
} else {
@ -179,13 +179,13 @@ export class ChannelTree {
}
}
} else if(this.selectedEntry instanceof ChannelEntry) {
if(settings.static_global(Settings.KEY_SWITCH_INSTANT_CHAT)) {
if(settings.getValue(Settings.KEY_SWITCH_INSTANT_CHAT)) {
const conversation = this.client.getChannelConversations().findOrCreateConversation(this.selectedEntry.channelId);
this.client.getChannelConversations().setSelectedConversation(conversation);
this.client.getSideBar().showChannel();
}
} else if(this.selectedEntry instanceof ServerEntry) {
if(settings.static_global(Settings.KEY_SWITCH_INSTANT_CHAT)) {
if(settings.getValue(Settings.KEY_SWITCH_INSTANT_CHAT)) {
const conversation = this.client.getChannelConversations().findOrCreateConversation(0);
this.client.getChannelConversations().setSelectedConversation(conversation);
this.client.getSideBar().showServer();

View File

@ -345,7 +345,7 @@ export class ClientEntry<Events extends ClientEvents = ClientEvents> extends Cha
}
this.voiceMuted = flagMuted;
this.channelTree.client.settings.changeServer(Settings.FN_CLIENT_MUTED(this.clientUid()), flagMuted);
this.channelTree.client.settings.setValue(Settings.FN_CLIENT_MUTED(this.clientUid()), flagMuted);
this.updateVoiceVolume();
this.events.fire("notify_mute_state_change", { muted: flagMuted });
@ -366,12 +366,12 @@ export class ClientEntry<Events extends ClientEvents = ClientEvents> extends Cha
this.channelTree.client.getSideBar().showClientInfo(this as any);
},
icon_class: "client-about",
visible: !settings.static_global(Settings.KEY_SWITCH_INSTANT_CLIENT)
visible: !settings.getValue(Settings.KEY_SWITCH_INSTANT_CLIENT)
}, {
callback: () => {},
type: contextmenu.MenuEntryType.HR,
name: "",
visible: !settings.static_global(Settings.KEY_SWITCH_INSTANT_CLIENT)
visible: !settings.getValue(Settings.KEY_SWITCH_INSTANT_CLIENT)
}
]
}
@ -763,8 +763,8 @@ export class ClientEntry<Events extends ClientEvents = ClientEvents> extends Cha
reorder_channel = true;
}
if(variable.key == "client_unique_identifier") {
this.voiceVolume = this.channelTree.client.settings.server(Settings.FN_CLIENT_VOLUME(this.clientUid()), 1);
const mute_status = this.channelTree.client.settings.server(Settings.FN_CLIENT_MUTED(this.clientUid()), false);
this.voiceVolume = this.channelTree.client.settings.getValue(Settings.FN_CLIENT_VOLUME(this.clientUid()), 1);
const mute_status = this.channelTree.client.settings.getValue(Settings.FN_CLIENT_MUTED(this.clientUid()), false);
this.setMuted(mute_status, mute_status); /* force only needed when we want to mute the client */
this.updateVoiceVolume();
log.debug(LogCategory.CLIENT, tr("Loaded client (%s) server specific properties. Volume: %o Muted: %o."), this.clientUid(), this.voiceVolume, this.voiceMuted);
@ -917,7 +917,7 @@ export class ClientEntry<Events extends ClientEvents = ClientEvents> extends Cha
this.voiceVolume = value;
this.updateVoiceVolume();
this.channelTree.client.settings.changeServer(Settings.FN_CLIENT_VOLUME(this.clientUid()), value);
this.channelTree.client.settings.setValue(Settings.FN_CLIENT_VOLUME(this.clientUid()), value);
this.events.fire("notify_audio_level_changed", { newValue: value });
}
@ -972,7 +972,7 @@ export class LocalClientEntry extends ClientEntry {
const old_name = this.properties.client_nickname;
this.updateVariables({ key: "client_nickname", value: new_name }); /* change it locally */
return this.handle.serverConnection.send_command("clientupdate", { client_nickname: new_name }).then(() => {
settings.changeGlobal(Settings.KEY_CONNECT_USERNAME, new_name);
settings.setValue(Settings.KEY_CONNECT_USERNAME, new_name);
this.channelTree.client.log.log("client.nickname.changed.own", {
client: this.log_data(),
old_name: old_name,

View File

@ -221,7 +221,7 @@ export class ServerEntry extends ChannelTreeEntry<ServerEvents> {
this.channelTree.client.getChannelConversations().setSelectedConversation(this.channelTree.client.getChannelConversations().findOrCreateConversation(0));
this.channelTree.client.getSideBar().showServer();
},
visible: !settings.static_global(Settings.KEY_SWITCH_INSTANT_CHAT)
visible: !settings.getValue(Settings.KEY_SWITCH_INSTANT_CHAT)
}, {
type: contextmenu.MenuEntryType.ENTRY,
icon_class: "client-virtualserver_edit",

View File

@ -89,7 +89,7 @@ if(!$.fn.dividerfy) {
apply_view(property, previous_p, next_p);
if(seperator_id)
settings.changeGlobal(Settings.FN_SEPARATOR_STATE(seperator_id), JSON.stringify({
settings.setValue(Settings.FN_SEPARATOR_STATE(seperator_id), JSON.stringify({
previous: previous_p,
next: next_p,
property: property
@ -130,7 +130,7 @@ if(!$.fn.dividerfy) {
if(seperator_id) {
try {
const config = JSON.parse(settings.global(Settings.FN_SEPARATOR_STATE(seperator_id), undefined));
const config = JSON.parse(settings.getValue(Settings.FN_SEPARATOR_STATE(seperator_id), undefined));
if(config) {
log.debug(LogCategory.GENERAL, tr("Applying previous changed sperator settings for %s: %o"), seperator_id, config);
apply_view(config.property, config.previous, config.next);

View File

@ -324,7 +324,7 @@ export function set_icon_size(size: string) {
loader.register_task(loader.Stage.JAVASCRIPT_INITIALIZING, {
name: "icon size init",
function: async () => {
set_icon_size((settings.static_global(Settings.KEY_ICON_SIZE) / 100).toFixed(2) + "em");
set_icon_size((settings.getValue(Settings.KEY_ICON_SIZE) / 100).toFixed(2) + "em");
},
priority: 10
});

View File

@ -167,7 +167,7 @@ class InfoController {
public sendConnectionState() {
const globallyConnected = server_connections.all_connections().findIndex(e => e.connected) !== -1;
const locallyConnected = this.currentHandler?.connected;
const multisession = !settings.static_global(Settings.KEY_DISABLE_MULTI_SESSION);
const multisession = !settings.getValue(Settings.KEY_DISABLE_MULTI_SESSION);
this.events.fire_react("notify_connection_state", {
state: {
@ -349,8 +349,8 @@ export function initializeControlBarController(events: Registry<ControlBarEvents
(event.globally ? server_connections.all_connections() : [server_connections.active_connection()]).filter(e => !!e).forEach(connection => {
connection.setAway(value);
});
settings.changeGlobal(Settings.KEY_CLIENT_STATE_AWAY, true);
settings.changeGlobal(Settings.KEY_CLIENT_AWAY_MESSAGE, typeof value === "boolean" ? "" : value);
settings.setValue(Settings.KEY_CLIENT_STATE_AWAY, true);
settings.setValue(Settings.KEY_CLIENT_AWAY_MESSAGE, typeof value === "boolean" ? "" : value);
};
if(event.promptMessage) {
@ -368,13 +368,13 @@ export function initializeControlBarController(events: Registry<ControlBarEvents
connection.setAway(false);
}
settings.changeGlobal(Settings.KEY_CLIENT_STATE_AWAY, false);
settings.setValue(Settings.KEY_CLIENT_STATE_AWAY, false);
}
});
events.on("action_toggle_microphone", event => {
/* change the default global setting */
settings.changeGlobal(Settings.KEY_CLIENT_STATE_MICROPHONE_MUTED, !event.enabled);
settings.setValue(Settings.KEY_CLIENT_STATE_MICROPHONE_MUTED, !event.enabled);
const current_connection_handler = infoHandler.getCurrentHandler();
if(current_connection_handler) {
@ -391,19 +391,19 @@ export function initializeControlBarController(events: Registry<ControlBarEvents
events.on("action_toggle_speaker", event => {
/* change the default global setting */
settings.changeGlobal(Settings.KEY_CLIENT_STATE_SPEAKER_MUTED, !event.enabled);
settings.setValue(Settings.KEY_CLIENT_STATE_SPEAKER_MUTED, !event.enabled);
infoHandler.getCurrentHandler()?.setSpeakerMuted(!event.enabled);
});
events.on("action_toggle_subscribe", event => {
settings.changeGlobal(Settings.KEY_CLIENT_STATE_SUBSCRIBE_ALL_CHANNELS, event.subscribe);
settings.setValue(Settings.KEY_CLIENT_STATE_SUBSCRIBE_ALL_CHANNELS, event.subscribe);
infoHandler.getCurrentHandler()?.setSubscribeToAllChannels(event.subscribe);
});
events.on("action_toggle_query", event => {
settings.changeGlobal(Settings.KEY_CLIENT_STATE_QUERY_SHOWN, event.show);
settings.setValue(Settings.KEY_CLIENT_STATE_QUERY_SHOWN, event.show);
infoHandler.getCurrentHandler()?.setQueriesShown(event.show);
});

View File

@ -279,7 +279,7 @@ const VideoButton = (props: { type: VideoBroadcastType }) => {
let dropdownText = props.type === "camera" ? tr("Start video broadcasting") : tr("Start screen sharing");
return (
<Button switched={true} colorTheme={"red"} autoSwitch={false} iconNormal={icon}
onToggle={() => events.fire("action_toggle_video", {enable: true, broadcastType: props.type, quickStart: settings.static_global(Settings.KEY_VIDEO_QUICK_SETUP)})}
onToggle={() => events.fire("action_toggle_video", {enable: true, broadcastType: props.type, quickStart: settings.getValue(Settings.KEY_VIDEO_QUICK_SETUP)})}
tooltip={tooltip} key={"enable"}>
<DropdownEntry icon={icon} text={dropdownText} onClick={() => events.fire("action_toggle_video", {enable: true, broadcastType: props.type})} />
{props.type === "camera" ? <VideoDeviceList key={"list"} /> : null}

View File

@ -12,7 +12,7 @@ import {LoadingDots} from "tc-shared/ui/react-elements/LoadingDots";
import {preview_image} from "tc-shared/ui/frames/image_preview";
import {joinClassList, useTr} from "tc-shared/ui/react-elements/Helper";
import {spawnContextMenu} from "tc-shared/ui/ContextMenu";
import {copy_to_clipboard} from "tc-shared/utils/helpers";
import {copyToClipboard} from "tc-shared/utils/helpers";
const cssStyle = require("./MusicPlaylistRenderer.scss");
@ -141,13 +141,13 @@ const PlaylistEntry = React.memo((props: { serverUniqueId: string, playlistId: n
{
type: "normal",
label: tr("Copy URL"),
click: () => { status.type === "song" ? copy_to_clipboard(status.url) : undefined; },
click: () => { status.type === "song" ? copyToClipboard(status.url) : undefined; },
visible: status.type === "song"
},
{
type: "normal",
label: tr("Copy description"),
click: () => { status.type === "song" ? copy_to_clipboard(status.description) : undefined; },
click: () => { status.type === "song" ? copyToClipboard(status.description) : undefined; },
visible: status.type === "song" && !!status.description
},
{

View File

@ -651,7 +651,7 @@ class ChannelVideoController {
let videoStreamingCount = 0;
if(this.localVideoController) {
const localBroadcasting = this.localVideoController.isBroadcasting();
if(localBroadcasting || settings.static_global(Settings.KEY_VIDEO_FORCE_SHOW_OWN_VIDEO)) {
if(localBroadcasting || settings.getValue(Settings.KEY_VIDEO_FORCE_SHOW_OWN_VIDEO)) {
videoIds.push(this.localVideoController.videoId);
if(localBroadcasting) {
videoStreamingCount++;
@ -675,7 +675,7 @@ class ChannelVideoController {
const controller = this.clientVideos[client.clientId()];
if(controller.isBroadcasting()) {
videoStreamingCount++;
} else if(!settings.static_global(Settings.KEY_VIDEO_SHOW_ALL_CLIENTS)) {
} else if(!settings.getValue(Settings.KEY_VIDEO_SHOW_ALL_CLIENTS)) {
continue;
}
videoIds.push(controller.videoId);

View File

@ -291,7 +291,7 @@ export function spawnBookmarkModal() {
button_connect_tab.on('click', () => {
boorkmak_connect(selected_bookmark as Bookmark, true);
modal.close();
}).toggle(!settings.static_global(Settings.KEY_DISABLE_MULTI_SESSION));
}).toggle(!settings.getValue(Settings.KEY_DISABLE_MULTI_SESSION));
button_connect.on('click', () => {
boorkmak_connect(selected_bookmark as Bookmark, false);

View File

@ -1,6 +1,6 @@
import {createInfoModal, createModal, Modal} from "../../ui/elements/Modal";
import {ChannelEntry} from "../../tree/Channel";
import {copy_to_clipboard} from "../../utils/helpers";
import {copyToClipboard} from "../../utils/helpers";
import * as tooltip from "../../ui/elements/Tooltip";
import {formatMessage} from "../../ui/frames/chat";
import {renderBBCodeAsJQuery} from "tc-shared/text/bbcode";
@ -21,7 +21,7 @@ export function openChannelInfo(channel: ChannelEntry) {
};
template.find(".button-copy").on('click', event => {
copy_to_clipboard(channel.properties.channel_description);
copyToClipboard(channel.properties.channel_description);
createInfoModal(tr("Description copied"), tr("The channel description has been copied to your clipboard!")).open();
});

View File

@ -1,7 +1,7 @@
import {ClientConnectionInfo, ClientEntry} from "../../tree/Client";
import PermissionType from "../../permission/PermissionType";
import {createInfoModal, createModal, Modal} from "../../ui/elements/Modal";
import {copy_to_clipboard} from "../../utils/helpers";
import {copyToClipboard} from "../../utils/helpers";
import * as i18nc from "../../i18n/country";
import * as tooltip from "../../ui/elements/Tooltip";
import * as moment from "moment";
@ -142,7 +142,7 @@ function apply_basic_info(client: ClientEntry, tag: JQuery, modal: Modal, callba
container.find(".value-dbid").text(client.properties.client_database_id);
container.find(".button-copy").on('click', event => {
copy_to_clipboard(client.clientUid());
copyToClipboard(client.clientUid());
createInfoModal(tr("Unique ID copied"), tr("The unique id has been copied to your clipboard!")).open();
});
}
@ -216,7 +216,7 @@ function apply_basic_info(client: ClientEntry, tag: JQuery, modal: Modal, callba
value.text(tr("loading..."));
container.find(".button-copy").on('click', event => {
copy_to_clipboard(value.text());
copyToClipboard(value.text());
createInfoModal(tr("Client IP copied"), tr("The client IP has been copied to your clipboard!")).open();
});

View File

@ -186,18 +186,18 @@ export function spawnInviteEditor(connection: ConnectionHandler) {
for (const s of invite_settings) {
s.node.on('change keyup', () => {
settings.changeGlobal(Settings.FN_INVITE_LINK_SETTING(s.key), s.value(s.node));
settings.setValue(Settings.FN_INVITE_LINK_SETTING(s.key), s.value(s.node));
update_link()
});
s.set_value(s.node, settings.global(Settings.FN_INVITE_LINK_SETTING(s.key), DefaultGeneratorSettings[s.key]));
s.set_value(s.node, settings.getValue(Settings.FN_INVITE_LINK_SETTING(s.key), DefaultGeneratorSettings[s.key]));
}
input_type.on('change', () => {
settings.changeGlobal(Settings.KEY_LAST_INVITE_LINK_TYPE, input_type.val() as string);
settings.setValue(Settings.KEY_LAST_INVITE_LINK_TYPE, input_type.val() as string);
update_buttons();
update_link();
}).val(settings.global(Settings.KEY_LAST_INVITE_LINK_TYPE));
}).val(settings.getValue(Settings.KEY_LAST_INVITE_LINK_TYPE));
button_copy.on('click', event => {
label_output.select();

View File

@ -160,7 +160,7 @@ export function spawnQueryManage(client: ConnectionHandler) {
import {createErrorModal, createInfoModal, createInputModal, createModal, Modal} from "../../ui/elements/Modal";
import {CommandResult, QueryListEntry} from "../../connection/ServerConnectionDeclaration";
import {SingleCommandHandler} from "../../connection/ConnectionBase";
import {copy_to_clipboard} from "../../utils/helpers";
import {copyToClipboard} from "../../utils/helpers";
import {spawnYesNo} from "../../ui/modal/ModalYesNo";
import * as log from "../../log";
import {LogCategory} from "../../log";
@ -326,7 +326,7 @@ export function spawnQueryManage(client: ConnectionHandler) {
detail_unique_id_copy.on('click', event => {
if (!selected_query) return;
copy_to_clipboard(selected_query.unique_id);
copyToClipboard(selected_query.unique_id);
createInfoModal(tr("Unique ID copied"), tr("The unique id has been successfully copied to your clipboard.")).open();
});

View File

@ -92,8 +92,8 @@ function settings_general_application(container: JQuery, modal: Modal) {
{
const option = container.find(".option-hostbanner-background") as JQuery<HTMLInputElement>;
option.on('change', event => {
settings.changeGlobal(Settings.KEY_HOSTBANNER_BACKGROUND, option[0].checked);
}).prop("checked", settings.static_global(Settings.KEY_HOSTBANNER_BACKGROUND));
settings.setValue(Settings.KEY_HOSTBANNER_BACKGROUND, option[0].checked);
}).prop("checked", settings.getValue(Settings.KEY_HOSTBANNER_BACKGROUND));
}
/* font size */
@ -109,7 +109,7 @@ function settings_general_application(container: JQuery, modal: Modal) {
select.on('change', event => {
const value = parseInt(select.val() as string);
settings.changeGlobal(Settings.KEY_FONT_SIZE, value);
settings.setValue(Settings.KEY_FONT_SIZE, value);
console.log("Changed font size to %dpx", value);
});
}
@ -118,8 +118,8 @@ function settings_general_application(container: JQuery, modal: Modal) {
{
const option = container.find(".option-all-permissions") as JQuery<HTMLInputElement>;
option.on('change', event => {
settings.changeGlobal(Settings.KEY_HOSTBANNER_BACKGROUND, option[0].checked);
}).prop("checked", settings.global(Settings.KEY_PERMISSIONS_SHOW_ALL));
settings.setValue(Settings.KEY_HOSTBANNER_BACKGROUND, option[0].checked);
}).prop("checked", settings.getValue(Settings.KEY_PERMISSIONS_SHOW_ALL));
}
}
@ -359,58 +359,58 @@ function settings_general_chat(container: JQuery, modal: Modal) {
const option_colloquial = container.find(".option-colloquial-timestamps") as JQuery<HTMLInputElement>;
option_colloquial.on('change', event => {
settings.changeGlobal(Settings.KEY_CHAT_COLLOQUIAL_TIMESTAMPS, option_colloquial[0].checked);
settings.setValue(Settings.KEY_CHAT_COLLOQUIAL_TIMESTAMPS, option_colloquial[0].checked);
});
option_fixed.on('change', event => {
settings.changeGlobal(Settings.KEY_CHAT_FIXED_TIMESTAMPS, option_fixed[0].checked);
settings.setValue(Settings.KEY_CHAT_FIXED_TIMESTAMPS, option_fixed[0].checked);
option_colloquial
.prop("disabled", option_fixed[0].checked)
.parents("label").toggleClass("disabled", option_fixed[0].checked);
if (option_fixed[0].checked) {
option_colloquial.prop("checked", false);
} else {
option_colloquial.prop("checked", settings.static_global(Settings.KEY_CHAT_COLLOQUIAL_TIMESTAMPS));
option_colloquial.prop("checked", settings.getValue(Settings.KEY_CHAT_COLLOQUIAL_TIMESTAMPS));
}
}).prop("checked", settings.static_global(Settings.KEY_CHAT_FIXED_TIMESTAMPS)).trigger('change');
}).prop("checked", settings.getValue(Settings.KEY_CHAT_FIXED_TIMESTAMPS)).trigger('change');
}
{
const option = container.find(".option-instant-channel-switch") as JQuery<HTMLInputElement>;
option.on('change', event => {
settings.changeGlobal(Settings.KEY_SWITCH_INSTANT_CHAT, option[0].checked);
}).prop("checked", settings.static_global(Settings.KEY_SWITCH_INSTANT_CHAT));
settings.setValue(Settings.KEY_SWITCH_INSTANT_CHAT, option[0].checked);
}).prop("checked", settings.getValue(Settings.KEY_SWITCH_INSTANT_CHAT));
}
{
const option = container.find(".option-instant-client-switch") as JQuery<HTMLInputElement>;
option.on('change', event => {
settings.changeGlobal(Settings.KEY_SWITCH_INSTANT_CLIENT, option[0].checked);
}).prop("checked", settings.static_global(Settings.KEY_SWITCH_INSTANT_CLIENT));
settings.setValue(Settings.KEY_SWITCH_INSTANT_CLIENT, option[0].checked);
}).prop("checked", settings.getValue(Settings.KEY_SWITCH_INSTANT_CLIENT));
}
{
const option = container.find(".option-colored-emojies") as JQuery<HTMLInputElement>;
option.on('change', event => {
settings.changeGlobal(Settings.KEY_CHAT_COLORED_EMOJIES, option[0].checked);
}).prop("checked", settings.static_global(Settings.KEY_CHAT_COLORED_EMOJIES));
settings.setValue(Settings.KEY_CHAT_COLORED_EMOJIES, option[0].checked);
}).prop("checked", settings.getValue(Settings.KEY_CHAT_COLORED_EMOJIES));
}
{
const option = container.find(".option-support-markdown") as JQuery<HTMLInputElement>;
option.on('change', event => {
settings.changeGlobal(Settings.KEY_CHAT_ENABLE_MARKDOWN, option[0].checked);
}).prop("checked", settings.static_global(Settings.KEY_CHAT_ENABLE_MARKDOWN));
settings.setValue(Settings.KEY_CHAT_ENABLE_MARKDOWN, option[0].checked);
}).prop("checked", settings.getValue(Settings.KEY_CHAT_ENABLE_MARKDOWN));
}
{
const option = container.find(".option-support-bbcode") as JQuery<HTMLInputElement>;
option.on('change', event => {
settings.changeGlobal(Settings.KEY_CHAT_ENABLE_BBCODE, option[0].checked);
}).prop("checked", settings.static_global(Settings.KEY_CHAT_ENABLE_BBCODE));
settings.setValue(Settings.KEY_CHAT_ENABLE_BBCODE, option[0].checked);
}).prop("checked", settings.getValue(Settings.KEY_CHAT_ENABLE_BBCODE));
}
{
const option = container.find(".option-url-tagging") as JQuery<HTMLInputElement>;
option.on('change', event => {
settings.changeGlobal(Settings.KEY_CHAT_TAG_URLS, option[0].checked);
}).prop("checked", settings.static_global(Settings.KEY_CHAT_TAG_URLS));
settings.setValue(Settings.KEY_CHAT_TAG_URLS, option[0].checked);
}).prop("checked", settings.getValue(Settings.KEY_CHAT_TAG_URLS));
}
/* Icon size */
{
@ -422,13 +422,13 @@ function settings_general_chat(container: JQuery, modal: Modal) {
min_value: 25,
max_value: 300,
step: 5,
initial_value: settings.static_global(Settings.KEY_ICON_SIZE),
initial_value: settings.getValue(Settings.KEY_ICON_SIZE),
value_field: container_value
});
container_slider.on('change', event => {
const value = parseInt(container_slider.attr("value") as string);
settings.changeGlobal(Settings.KEY_ICON_SIZE, value);
settings.setValue(Settings.KEY_ICON_SIZE, value);
console.log("Changed icon size to %sem", (value / 100).toFixed(2));
set_icon_size((value / 100).toFixed(2) + "em");
@ -549,7 +549,7 @@ function settings_audio_speaker(container: JQuery, modal: Modal) {
min_value: 0,
max_value: 100,
step: 1,
initial_value: settings.static_global(Settings.KEY_SOUND_MASTER, 100),
initial_value: settings.getValue(Settings.KEY_SOUND_MASTER, 100),
value_field: [container_master.find(".container-value")]
});
slider.on('change', event => {
@ -557,7 +557,7 @@ function settings_audio_speaker(container: JQuery, modal: Modal) {
if (aplayer.set_master_volume)
aplayer.set_master_volume(volume / 100);
settings.changeGlobal(Settings.KEY_SOUND_MASTER, volume);
settings.setValue(Settings.KEY_SOUND_MASTER, volume);
});
}
@ -568,13 +568,13 @@ function settings_audio_speaker(container: JQuery, modal: Modal) {
min_value: 0,
max_value: 100,
step: 1,
initial_value: settings.static_global(Settings.KEY_SOUND_MASTER_SOUNDS, 100),
initial_value: settings.getValue(Settings.KEY_SOUND_MASTER_SOUNDS, 100),
value_field: [container_soundpack.find(".container-value")]
});
slider.on('change', event => {
const volume = parseInt(slider.attr('value'));
set_master_volume(volume / 100);
settings.changeGlobal(Settings.KEY_SOUND_MASTER_SOUNDS, volume);
settings.setValue(Settings.KEY_SOUND_MASTER_SOUNDS, volume);
});
}
}

View File

@ -1089,7 +1089,7 @@ const ContainerSimpleSettings = React.memo(() => {
});
const SettingsContainer = React.memo(() => {
const [ advancedEnabled, setAdvancedEnabled ] = useState(settings.static_global(Settings.KEY_CHANNEL_EDIT_ADVANCED));
const [ advancedEnabled, setAdvancedEnabled ] = useState(settings.getValue(Settings.KEY_CHANNEL_EDIT_ADVANCED));
useEffect(() => settings.globalChangeListener(Settings.KEY_CHANNEL_EDIT_ADVANCED, newValue => setAdvancedEnabled(newValue)));
return (
@ -1105,7 +1105,7 @@ const SettingsContainer = React.memo(() => {
});
const ButtonToggleAdvanced = React.memo(() => {
const [ advancedEnabled, setAdvancedEnabled ] = useState(settings.static_global(Settings.KEY_CHANNEL_EDIT_ADVANCED));
const [ advancedEnabled, setAdvancedEnabled ] = useState(settings.getValue(Settings.KEY_CHANNEL_EDIT_ADVANCED));
settings.globalChangeListener(Settings.KEY_CHANNEL_EDIT_ADVANCED, newValue => setAdvancedEnabled(newValue));
@ -1114,7 +1114,7 @@ const ButtonToggleAdvanced = React.memo(() => {
className={cssStyle.advancedSwitch}
value={advancedEnabled}
label={<Translatable>Advanced mode</Translatable>}
onChange={newState => settings.changeGlobal(Settings.KEY_CHANNEL_EDIT_ADVANCED, newState)}
onChange={newState => settings.setValue(Settings.KEY_CHANNEL_EDIT_ADVANCED, newState)}
/>
)
});

View File

@ -86,11 +86,11 @@ class ConnectController {
this.history = undefined;
this.defaultAddress = "ts.teaspeak.de";
this.historyShown = settings.static_global(Settings.KEY_CONNECT_SHOW_HISTORY);
this.historyShown = settings.getValue(Settings.KEY_CONNECT_SHOW_HISTORY);
this.currentAddress = settings.static_global(Settings.KEY_CONNECT_ADDRESS);
this.currentProfile = findConnectProfile(settings.static_global(Settings.KEY_CONNECT_PROFILE)) || defaultConnectProfile();
this.currentNickname = settings.static_global(Settings.KEY_CONNECT_USERNAME);
this.currentAddress = settings.getValue(Settings.KEY_CONNECT_ADDRESS);
this.currentProfile = findConnectProfile(settings.getValue(Settings.KEY_CONNECT_PROFILE)) || defaultConnectProfile();
this.currentNickname = settings.getValue(Settings.KEY_CONNECT_USERNAME);
this.addressChanged = false;
this.nicknameChanged = false;
@ -178,7 +178,7 @@ class ConnectController {
this.historyShown = event.enabled;
this.sendProperty("historyShown").then(undefined);
settings.changeGlobal(Settings.KEY_CONNECT_SHOW_HISTORY, event.enabled);
settings.setValue(Settings.KEY_CONNECT_SHOW_HISTORY, event.enabled);
});
@ -214,7 +214,7 @@ class ConnectController {
this.uiEvents.on("action_set_nickname", event => {
if(this.currentNickname !== event.nickname) {
this.currentNickname = event.nickname;
settings.changeGlobal(Settings.KEY_CONNECT_USERNAME, event.nickname);
settings.setValue(Settings.KEY_CONNECT_USERNAME, event.nickname);
if(event.updateUi) {
this.sendProperty("nickname").then(undefined);
@ -297,7 +297,7 @@ class ConnectController {
setSelectedAddress(address: string | undefined, validate: boolean, updateUi: boolean) {
if(this.currentAddress !== address) {
this.currentAddress = address;
settings.changeGlobal(Settings.KEY_CONNECT_ADDRESS, address);
settings.setValue(Settings.KEY_CONNECT_ADDRESS, address);
this.setSelectedHistoryId(-1);
if(updateUi) {
@ -316,7 +316,7 @@ class ConnectController {
this.currentProfile = profile;
this.sendProperty("profiles").then(undefined);
settings.changeGlobal(Settings.KEY_CONNECT_PROFILE, profile.id);
settings.setValue(Settings.KEY_CONNECT_PROFILE, profile.id);
/* Clear out the nickname on profile switch and use the default nickname */
this.uiEvents.fire("action_set_nickname", { nickname: undefined, validate: true, updateUi: true });

View File

@ -57,11 +57,11 @@ function initializeController(connection: ConnectionHandler, events: Registry<Ec
});
events.on("action_toggle_tests", event => {
settings.changeGlobal(Settings.KEY_VOICE_ECHO_TEST_ENABLED, event.enabled);
settings.setValue(Settings.KEY_VOICE_ECHO_TEST_ENABLED, event.enabled);
});
events.on("query_test_state", () => {
events.fire_react("notify_tests_toggle", {enabled: settings.global(Settings.KEY_VOICE_ECHO_TEST_ENABLED)});
events.fire_react("notify_tests_toggle", {enabled: settings.getValue(Settings.KEY_VOICE_ECHO_TEST_ENABLED)});
});
events.on("notify_destroy", settings.globalChangeListener(Settings.KEY_VOICE_ECHO_TEST_ENABLED, value => {

View File

@ -2,7 +2,7 @@ import {spawnReactModal} from "tc-shared/ui/react-elements/Modal";
import {ModalGlobalSettingsEditor} from "tc-shared/ui/modal/global-settings-editor/Renderer";
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 {RegistryValueType, settings, Settings, RegistryKey} from "tc-shared/settings";
export function spawnGlobalSettingsEditor() {
const events = new Registry<ModalGlobalSettingsEditorEvents>();
@ -21,7 +21,7 @@ function initializeController(events: Registry<ModalGlobalSettingsEditorEvents>)
const settingsList: Setting[] = [];
for(const key of Settings.KEYS) {
const setting = Settings[key] as SettingsKey<ConfigValueTypes>;
const setting = Settings[key] as RegistryKey<RegistryValueType>;
settingsList.push({
key: setting.key,
description: setting.description,
@ -38,7 +38,7 @@ function initializeController(events: Registry<ModalGlobalSettingsEditorEvents>)
});
events.on("query_setting", event => {
const setting = Settings.KEYS.map(setting => Settings[setting] as SettingsKey<ConfigValueTypes>).find(e => e.key === event.setting);
const setting = Settings.KEYS.map(setting => Settings[setting] as RegistryKey<RegistryValueType>).find(e => e.key === event.setting);
if(typeof setting === "undefined") {
events.fire("notify_setting", {
setting: event.setting,
@ -56,18 +56,18 @@ function initializeController(events: Registry<ModalGlobalSettingsEditorEvents>)
type: setting.valueType,
defaultValue: setting.defaultValue
},
value: settings.global(setting, undefined)
value: settings.getValue(setting, undefined)
});
});
events.on("action_set_value", event => {
const setting = Settings.KEYS.map(setting => Settings[setting] as SettingsKey<ConfigValueTypes>).find(e => e.key === event.setting);
const setting = Settings.KEYS.map(setting => Settings[setting] as RegistryKey<RegistryValueType>).find(e => e.key === event.setting);
if(typeof setting === "undefined") {
return;
}
/* the change will may already trigger a notify_setting_value, but just to ensure we're fiering it later as well */
settings.changeGlobal(setting, event.value);
settings.setValue(setting, event.value);
events.fire_react("notify_setting_value", { setting: event.setting, value: event.value });
});

View File

@ -1,9 +1,9 @@
import {ConfigValueTypeNames} from "tc-shared/settings";
import {RegistryValueTypeNames} from "tc-shared/settings";
export interface Setting {
key: string;
type: ConfigValueTypeNames;
type: RegistryValueTypeNames;
description: string | undefined;
defaultValue: any | undefined;

View File

@ -889,7 +889,7 @@ function initializePermissionEditor(connection: ConnectionHandler, modalEvents:
};
events.fire_react("query_permission_list_result", {
hideSenselessPermissions: !settings.static_global(Settings.KEY_PERMISSIONS_SHOW_ALL),
hideSenselessPermissions: !settings.getValue(Settings.KEY_PERMISSIONS_SHOW_ALL),
permissions: (groups || []).map(visitGroup)
});
});

View File

@ -14,7 +14,7 @@ import {Button} from "tc-shared/ui/react-elements/Button";
import {IconRenderer, RemoteIconRenderer} from "tc-shared/ui/react-elements/Icon";
import {ConnectionHandler} from "tc-shared/ConnectionHandler";
import * as contextmenu from "tc-shared/ui/elements/ContextMenu";
import {copy_to_clipboard} from "tc-shared/utils/helpers";
import {copyToClipboard} from "tc-shared/utils/helpers";
import {createInfoModal} from "tc-shared/ui/elements/Modal";
import {getIconManager} from "tc-shared/file/Icons";
@ -661,7 +661,7 @@ const PermissionEntryRow = (props: {
entries.push({
type: contextmenu.MenuEntryType.ENTRY,
name: tr("Copy permission name"),
callback: () => copy_to_clipboard(props.permission)
callback: () => copyToClipboard(props.permission)
});
contextmenu.spawn_context_menu(e.pageX, e.pageY, ...entries);

View File

@ -10,7 +10,7 @@ import {Translatable} from "tc-shared/ui/react-elements/i18n";
import {LoadingDots} from "tc-shared/ui/react-elements/LoadingDots";
import * as contextmenu from "tc-shared/ui/elements/ContextMenu";
import {MenuEntryType, spawn_context_menu} from "tc-shared/ui/elements/ContextMenu";
import {copy_to_clipboard} from "tc-shared/utils/helpers";
import {copyToClipboard} from "tc-shared/utils/helpers";
import {FlatInputField} from "tc-shared/ui/react-elements/InputField";
import {arrayBufferBase64} from "tc-shared/utils/buffers";
import {tra} from "tc-shared/i18n/localize";
@ -513,7 +513,7 @@ class ServerClientList extends React.Component<{ connection: ConnectionHandler,
type: contextmenu.MenuEntryType.ENTRY,
name: tr("Copy unique id"),
icon_class: 'client-copy',
callback: () => copy_to_clipboard(client.uniqueId)
callback: () => copyToClipboard(client.uniqueId)
}, contextmenu.Entry.HR(), {
type: contextmenu.MenuEntryType.ENTRY,
name: tr("Refresh"),

View File

@ -253,7 +253,7 @@ export function initialize_audio_microphone_controller(events: Registry<Micropho
break;
case "rnnoise":
value = settings.static_global(Settings.KEY_RNNOISE_FILTER);
value = settings.getValue(Settings.KEY_RNNOISE_FILTER);
break;
default:
@ -312,7 +312,7 @@ export function initialize_audio_microphone_controller(events: Registry<Micropho
case "rnnoise":
if (!ensure_type("boolean")) return;
settings.changeGlobal(Settings.KEY_RNNOISE_FILTER, event.value);
settings.setValue(Settings.KEY_RNNOISE_FILTER, event.value);
break;
default:

View File

@ -446,7 +446,7 @@ function initializeController(events: Registry<NotificationSettingsEvents>) {
events.fire_react("notify_event_info", {
key: event.key,
name: groupNames[event.key] || event.key,
log: settings.global(Settings.FN_EVENTS_LOG_ENABLED(event.key), true) ? "enabled" : "disabled",
log: settings.getValue(Settings.FN_EVENTS_LOG_ENABLED(event.key), true) ? "enabled" : "disabled",
notification: getRegisteredNotificationDispatchers().findIndex(e => e as any === event.key) === -1 ? "unavailable" : isNotificationEnabled(event.key as any) ? "enabled" : "disabled",
focus: isFocusRequestEnabled(event.key as any) ? "enabled" : "disabled"
});
@ -455,15 +455,15 @@ function initializeController(events: Registry<NotificationSettingsEvents>) {
events.on("action_set_state", event => {
switch (event.state) {
case "log":
settings.changeGlobal(Settings.FN_EVENTS_LOG_ENABLED(event.key), event.value === "enabled");
settings.setValue(Settings.FN_EVENTS_LOG_ENABLED(event.key), event.value === "enabled");
break;
case "notification":
settings.changeGlobal(Settings.FN_EVENTS_NOTIFICATION_ENABLED(event.key), event.value === "enabled");
settings.setValue(Settings.FN_EVENTS_NOTIFICATION_ENABLED(event.key), event.value === "enabled");
break;
case "focus":
settings.changeGlobal(Settings.FN_EVENTS_FOCUS_ENABLED(event.key), event.value === "enabled");
settings.setValue(Settings.FN_EVENTS_FOCUS_ENABLED(event.key), event.value === "enabled");
break;
}

View File

@ -62,7 +62,7 @@ export const initializeTransferInfoController = (connection: ConnectionHandler,
};
events.on("action_toggle_finished_transfers", event => {
settings.changeGlobal(Settings.KEY_TRANSFERS_SHOW_FINISHED, event.visible);
settings.setValue(Settings.KEY_TRANSFERS_SHOW_FINISHED, event.visible);
});
events.on("action_remove_finished", () => {
@ -93,7 +93,7 @@ export const initializeTransferInfoController = (connection: ConnectionHandler,
events.fire_react("query_transfer_result", {
status: "success",
transfers: transfers,
showFinished: settings.global(Settings.KEY_TRANSFERS_SHOW_FINISHED)
showFinished: settings.getValue(Settings.KEY_TRANSFERS_SHOW_FINISHED)
});
});

View File

@ -119,8 +119,8 @@ function updateBroadcastConfigFromSource(source: VideoSource, constraints: Video
async function generateAndApplyDefaultConfig(source: VideoSource) : Promise<VideoBroadcastConfig> {
const videoTrack = source.getStream().getVideoTracks()[0];
let maxHeight = settings.static_global(Settings.KEY_VIDEO_DEFAULT_MAX_HEIGHT);
let maxWidth = settings.static_global(Settings.KEY_VIDEO_DEFAULT_MAX_WIDTH);
let maxHeight = settings.getValue(Settings.KEY_VIDEO_DEFAULT_MAX_HEIGHT);
let maxWidth = settings.getValue(Settings.KEY_VIDEO_DEFAULT_MAX_WIDTH);
const trackSettings = videoTrack.getSettings();
const capabilities = source.getCapabilities();
@ -154,8 +154,8 @@ async function generateAndApplyDefaultConfig(source: VideoSource) : Promise<Vide
}
}
broadcastConstraints.dynamicQuality = settings.static_global(Settings.KEY_VIDEO_DYNAMIC_QUALITY);
broadcastConstraints.dynamicFrameRate = settings.static_global(Settings.KEY_VIDEO_DYNAMIC_FRAME_RATE);
broadcastConstraints.dynamicQuality = settings.getValue(Settings.KEY_VIDEO_DYNAMIC_QUALITY);
broadcastConstraints.dynamicFrameRate = settings.getValue(Settings.KEY_VIDEO_DYNAMIC_FRAME_RATE);
try {
await applyBroadcastConfig(source, broadcastConstraints);

View File

@ -96,7 +96,7 @@ const nodeToText = (element: Node) => {
const content = [...element.childNodes].map(nodeToText).join("");
if(element.href) {
if(settings.static_global(Settings.KEY_CHAT_ENABLE_MARKDOWN)) {
if(settings.getValue(Settings.KEY_CHAT_ENABLE_MARKDOWN)) {
if(content && element.title) {
return `[${content}](${element.href} "${element.title}")`;
} else if(content) {
@ -104,7 +104,7 @@ const nodeToText = (element: Node) => {
} else {
return `[${element.href}](${element.href})`;
}
} else if(settings.static_global(Settings.KEY_CHAT_ENABLE_BBCODE)) {
} else if(settings.getValue(Settings.KEY_CHAT_ENABLE_BBCODE)) {
if(content) {
return `[url=${element.href}]${content}"[/url]`;
} else {
@ -308,14 +308,14 @@ export interface ChatBoxState {
}
const MarkdownFormatHelper = () => {
const [ visible, setVisible ] = useState(settings.global(Settings.KEY_CHAT_ENABLE_MARKDOWN));
const [ visible, setVisible ] = useState(settings.getValue(Settings.KEY_CHAT_ENABLE_MARKDOWN));
settings.events.reactUse("notify_setting_changed", event => {
if(event.setting !== Settings.KEY_CHAT_ENABLE_MARKDOWN.key) {
return;
}
setVisible(settings.global(Settings.KEY_CHAT_ENABLE_MARKDOWN));
setVisible(settings.getValue(Settings.KEY_CHAT_ENABLE_MARKDOWN));
});
if(visible) {

View File

@ -34,7 +34,7 @@ export class ContextDivider extends React.Component<ContextDividerProperties, Co
this.value = this.props.defaultValue;
try {
const config = JSON.parse(settings.global(Settings.FN_SEPARATOR_STATE(this.props.id), undefined));
const config = JSON.parse(settings.getValue(Settings.FN_SEPARATOR_STATE(this.props.id), undefined));
if(typeof config.value !== "number")
throw "Invalid value";
@ -150,7 +150,7 @@ export class ContextDivider extends React.Component<ContextDividerProperties, Co
document.removeEventListener('touchcancel', this.listenerUp);
document.documentElement.classList.remove(cssStyle.documentActiveClass);
settings.changeGlobal(Settings.FN_SEPARATOR_STATE(this.props.id), JSON.stringify({
settings.setValue(Settings.FN_SEPARATOR_STATE(this.props.id), JSON.stringify({
value: this.value
}));
}

View File

@ -1,5 +1,5 @@
import {Dispatch, SetStateAction, useEffect, useMemo, useState} from "react";
import {ConfigValueTypes, settings, SettingsKey, ValuedSettingsKey} from "tc-shared/settings";
import {RegistryValueType, settings, RegistryKey, ValuedRegistryKey} from "tc-shared/settings";
export function useDependentState<S>(
factory: (prevState?: S) => S,
@ -34,10 +34,10 @@ export function joinClassList(...classes: any[]) : string {
return classes.filter(value => typeof value === "string" && value.length > 0).join(" ");
}
export function useGlobalSetting<V extends ConfigValueTypes, DV>(key: SettingsKey<V>, defaultValue: DV) : V | DV;
export function useGlobalSetting<V extends ConfigValueTypes>(key: ValuedSettingsKey<V>, defaultValue?: V) : V;
export function useGlobalSetting<V extends ConfigValueTypes, DV>(key: SettingsKey<V>, defaultValue: DV) : V | DV {
const [ value, setValue ] = useState(settings.global(key, defaultValue));
export function useGlobalSetting<V extends RegistryValueType, DV>(key: RegistryKey<V>, defaultValue: DV) : V | DV;
export function useGlobalSetting<V extends RegistryValueType>(key: ValuedRegistryKey<V>, defaultValue?: V) : V;
export function useGlobalSetting<V extends RegistryValueType, DV>(key: RegistryKey<V>, defaultValue: DV) : V | DV {
const [ value, setValue ] = useState(settings.getValue(key, defaultValue));
useEffect(() => settings.globalChangeListener(key, value => setValue(value)), []);
return value;

View File

@ -1,16 +1,11 @@
import {getIpcInstance as getIPCInstance} from "../../../ipc/BrowserIPC";
import {Settings, SettingsKey} from "../../../settings";
import {AppParameters} from "../../../settings";
import {
Controller2PopoutMessages, EventControllerBase,
PopoutIPCMessage
} from "../../../ui/react-elements/external-modal/IPCMessage";
import {Registry, RegistryMap} from "../../../events";
const kSettingIPCChannel: SettingsKey<string> = {
key: "ipc-channel",
valueType: "string"
};
let controller: PopoutController;
export function getPopoutController() {
if(!controller)
@ -25,9 +20,9 @@ class PopoutController extends EventControllerBase<"popout"> {
constructor() {
super();
this.ipcRemoteId = Settings.instance.static(Settings.KEY_IPC_REMOTE_ADDRESS, "invalid");
this.ipcRemoteId = AppParameters.getValue(AppParameters.KEY_IPC_REMOTE_ADDRESS, "invalid");
this.ipcChannel = getIPCInstance().createChannel(this.ipcRemoteId, Settings.instance.static(kSettingIPCChannel, "invalid"));
this.ipcChannel = getIPCInstance().createChannel(this.ipcRemoteId, AppParameters.getValue(AppParameters.KEY_IPC_REMOTE_ADDRESS, "invalid"));
this.ipcChannel.messageHandler = this.handleIPCMessage.bind(this);
}

View File

@ -4,7 +4,7 @@ import * as i18n from "../../../i18n/localize";
import {Stage} from "tc-loader";
import {AbstractModal, ModalRenderer} from "../../../ui/react-elements/ModalDefinitions";
import {Settings, SettingsKey} from "../../../settings";
import {AppParameters} from "../../../settings";
import {getPopoutController} from "./PopoutController";
import {findPopoutHandler} from "../../../ui/react-elements/external-modal/PopoutRegistry";
import {RegistryMap} from "../../../events";
@ -23,11 +23,6 @@ let modalRenderer: ModalRenderer;
let modalInstance: AbstractModal;
let modalClass: new (events: RegistryMap, userData: any) => AbstractModal;
const kSettingModalTarget: SettingsKey<string> = {
key: "modal-target",
valueType: "string"
};
loader.register_task(Stage.JAVASCRIPT_INITIALIZING, {
name: "setup",
priority: 110,
@ -73,7 +68,7 @@ loader.register_task(Stage.JAVASCRIPT_INITIALIZING, {
name: "modal class loader",
priority: 10,
function: async () => {
const modalTarget = Settings.instance.static(kSettingModalTarget, "unknown");
const modalTarget = AppParameters.getValue(AppParameters.KEY_MODAL_TARGET, "unknown");
console.error("Loading modal class %s", modalTarget);
try {
const handler = findPopoutHandler(modalTarget);

View File

@ -2,7 +2,7 @@ import * as React from "react";
import * as loader from "tc-loader";
import {Stage} from "tc-loader";
import {getIpcInstance, IPCChannel} from "tc-shared/ipc/BrowserIPC";
import {Settings} from "tc-shared/settings";
import {AppParameters} from "tc-shared/settings";
import {generateDragElement, setupDragData} from "tc-shared/ui/tree/DragHelper";
import {ClientIcon} from "svg-sprites/client-icons";
@ -85,6 +85,6 @@ loader.register_task(Stage.JAVASCRIPT_INITIALIZING, {
priority: 10,
function: async () => {
const ipc = getIpcInstance();
ipcChannel = ipc.createChannel(Settings.instance.static(Settings.KEY_IPC_REMOTE_ADDRESS, ipc.getLocalAddress()), kIpcChannel);
ipcChannel = ipc.createChannel(AppParameters.getValue(AppParameters.KEY_IPC_REMOTE_ADDRESS, ipc.getLocalAddress()), kIpcChannel);
}
});

View File

@ -145,7 +145,7 @@ export class RendererChannel extends React.Component<{ channel: RDPChannel }, {}
}}
onDoubleClick={() => events.fire("action_channel_join", { treeEntryId: entryId })}
onContextMenu={event => {
if (settings.static(Settings.KEY_DISABLE_CONTEXT_MENU)) {
if (settings.getValue(Settings.KEY_DISABLE_CONTEXT_MENU)) {
return;
}

View File

@ -179,7 +179,7 @@ export class RendererClient extends React.Component<{ client: RDPClient }, {}> {
<div className={clientStyle.clientEntry + " " + viewStyle.treeEntry + " " + (selected ? viewStyle.selected : "")}
style={{ top: (client.offsetTop * ChannelTreeView.EntryHeightEm) + "em" }}
onContextMenu={event => {
if (settings.static(Settings.KEY_DISABLE_CONTEXT_MENU)) {
if (settings.getValue(Settings.KEY_DISABLE_CONTEXT_MENU)) {
return;
}

View File

@ -49,7 +49,7 @@ export class ServerRenderer extends React.Component<{ server: RDPServer }, {}> {
this.props.server.select("auto");
}}
onContextMenu={event => {
if (settings.static(Settings.KEY_DISABLE_CONTEXT_MENU)) {
if (settings.getValue(Settings.KEY_DISABLE_CONTEXT_MENU)) {
return;
}

View File

@ -25,7 +25,7 @@ export function same_day(a: number | Date, b: number | Date) {
}
export function date_format(date: Date, now: Date, ignore_settings?: boolean) : ColloquialFormat {
if(!ignore_settings && !settings.static_global(Settings.KEY_CHAT_COLLOQUIAL_TIMESTAMPS))
if(!ignore_settings && !settings.getValue(Settings.KEY_CHAT_COLLOQUIAL_TIMESTAMPS))
return ColloquialFormat.GENERAL;
if(dateEqual(date, now))
@ -87,7 +87,7 @@ export function format_chat_time(date: Date) : {
next_update: 0
};
if(settings.static_global(Settings.KEY_CHAT_FIXED_TIMESTAMPS)) {
if(settings.getValue(Settings.KEY_CHAT_FIXED_TIMESTAMPS)) {
const format = format_date_colloquial(date, current_timestamp);
result.result = format.result;
result.next_update = 0; /* TODO: Update on day change? */

View File

@ -9,21 +9,22 @@ export function hashPassword(password: string) : Promise<string> {
});
}
export const copy_to_clipboard = str => {
export const copyToClipboard = str => {
console.log(tr("Copy text to clipboard: %s"), str);
const el = document.createElement('textarea');
el.value = str;
el.setAttribute('readonly', '');
el.style.position = 'absolute';
el.style.left = '-9999px';
document.body.appendChild(el);
const selected =
document.getSelection().rangeCount > 0
? document.getSelection().getRangeAt(0)
: false;
el.select();
const element = document.createElement('textarea');
element.value = str;
element.setAttribute('readonly', '');
element.style.position = 'absolute';
element.style.left = '-9999px';
document.body.appendChild(element);
const selected = document.getSelection().rangeCount > 0 ? document.getSelection().getRangeAt(0) : false;
element.select();
document.execCommand('copy');
document.body.removeChild(el);
document.body.removeChild(element);
if (selected) {
document.getSelection().removeAllRanges();
document.getSelection().addRange(selected);

View File

@ -299,7 +299,7 @@ class VideoViewer {
@EventHandler<VideoViewerEvents>("action_toggle_side_bar")
private handleActionToggleSidebar(event: VideoViewerEvents["action_toggle_side_bar"]) {
settings.changeGlobal(Settings.KEY_W2G_SIDEBAR_COLLAPSED, !event.shown);
settings.setValue(Settings.KEY_W2G_SIDEBAR_COLLAPSED, !event.shown);
}
@EventHandler<VideoViewerEvents>("notify_video")

View File

@ -247,7 +247,7 @@ const WatcherList = (props: { events: Registry<VideoViewerEvents>, handlerId: st
};
const ToggleSidebarButton = (props: { events: Registry<VideoViewerEvents> }) => {
const [ visible, setVisible ] = useState(settings.global(Settings.KEY_W2G_SIDEBAR_COLLAPSED));
const [ visible, setVisible ] = useState(settings.getValue(Settings.KEY_W2G_SIDEBAR_COLLAPSED));
props.events.reactUse("action_toggle_side_bar", event => setVisible(!event.shown));
@ -272,7 +272,7 @@ const ButtonUnfollow = (props: { events: Registry<VideoViewerEvents> }) => {
};
const Sidebar = (props: { events: Registry<VideoViewerEvents>, handlerId: string }) => {
const [ visible, setVisible ] = useState(!settings.global(Settings.KEY_W2G_SIDEBAR_COLLAPSED));
const [ visible, setVisible ] = useState(!settings.getValue(Settings.KEY_W2G_SIDEBAR_COLLAPSED));
props.events.reactUse("action_toggle_side_bar", event => setVisible(event.shown));

View File

@ -101,7 +101,7 @@ export class RecorderProfile {
{
let config = {};
try {
config = settings.static_global(Settings.FN_PROFILE_RECORD(this.name), {}) as RecorderProfileConfig;
config = settings.getValue(Settings.FN_PROFILE_RECORD(this.name), {}) as RecorderProfileConfig;
} catch (error) {
logWarn(LogCategory.AUDIO, tr("Failed to load old recorder profile config for %s"), this.name);
}
@ -175,7 +175,7 @@ export class RecorderProfile {
private save() {
if(!this.volatile) {
settings.changeGlobal(Settings.FN_PROFILE_RECORD(this.name), this.config);
settings.setValue(Settings.FN_PROFILE_RECORD(this.name), this.config);
}
}

View File

@ -2,8 +2,9 @@ import {Settings, settings} from "tc-shared/settings";
import {server_connections} from "tc-shared/ConnectionManager";
window.addEventListener("beforeunload", event => {
if(settings.static(Settings.KEY_DISABLE_UNLOAD_DIALOG))
if(settings.getValue(Settings.KEY_DISABLE_UNLOAD_DIALOG)) {
return;
}
const active_connections = server_connections.all_connections().filter(e => e.connected);
if(active_connections.length == 0) return;

View File

@ -148,7 +148,7 @@ export class ServerConnection extends AbstractServerConnection {
let availableSockets: WrappedWebSocket[] = [];
proxySocket:
if(!settings.static_global(Settings.KEY_CONNECT_NO_DNSPROXY)) {
if(!settings.getValue(Settings.KEY_CONNECT_NO_DNSPROXY)) {
let host;
if(Regex.IP_V4.test(address.host)) {
host = address.host.replace(/\./g, "-") + ".con-gate.work";