From e1e98b07d51a0dee17e794a7900580c6899e105e Mon Sep 17 00:00:00 2001 From: WolverinDEV Date: Thu, 25 Mar 2021 12:35:59 +0100 Subject: [PATCH] Renamed device_id to deviceId --- shared/js/audio/Player.ts | 2 +- shared/js/ui/frames/control-bar/Controller.ts | 14 +++++++------- shared/js/ui/modal/ModalSettings.tsx | 7 ++++--- web/app/audio/Player.ts | 4 ++-- 4 files changed, 14 insertions(+), 13 deletions(-) diff --git a/shared/js/audio/Player.ts b/shared/js/audio/Player.ts index c0fcbd7a..7ad14a33 100644 --- a/shared/js/audio/Player.ts +++ b/shared/js/audio/Player.ts @@ -1,5 +1,5 @@ export interface OutputDevice { - device_id: string; + deviceId: string; driver: string; name: string; diff --git a/shared/js/ui/frames/control-bar/Controller.ts b/shared/js/ui/frames/control-bar/Controller.ts index 7be6b261..cd873d88 100644 --- a/shared/js/ui/frames/control-bar/Controller.ts +++ b/shared/js/ui/frames/control-bar/Controller.ts @@ -310,15 +310,15 @@ class InfoController { } const devices = await backend.getAvailableDevices(); - const selectedDeviceId = backend.getCurrentDevice()?.device_id; + const selectedDeviceId = backend.getCurrentDevice()?.deviceId; const defaultDeviceId = backend.getDefaultDeviceId(); this.events.fire_react("notify_speaker_list", { state: "initialized", devices: devices.map(device => { let selected = false; - if(selectedDeviceId === OutputDevice.DefaultDeviceId && device.device_id === defaultDeviceId) { + if(selectedDeviceId === OutputDevice.DefaultDeviceId && device.deviceId === defaultDeviceId) { selected = true; - } else if(selectedDeviceId === device.device_id) { + } else if(selectedDeviceId === device.deviceId) { selected = true; } @@ -326,7 +326,7 @@ class InfoController { name: device.name, driver: device.driver, - id: device.device_id, + id: device.deviceId, selected: selected } }) @@ -513,13 +513,13 @@ export function initializeControlBarController(events: Registry device.device_id === event.targetDeviceId); + const device = devices.find(device => device.deviceId === event.targetDeviceId); if(!device) { throw tr("Target device could not be found."); } - await getAudioBackend().setCurrentDevice(device.device_id); - settings.setValue(Settings.KEY_SPEAKER_DEVICE_ID, device.device_id); + await getAudioBackend().setCurrentDevice(device.deviceId); + settings.setValue(Settings.KEY_SPEAKER_DEVICE_ID, device.deviceId); } catch (error) { createErrorModal(tr("Failed to change speaker"), tr("Failed to change speaker.\nTarget device could not be found.")).open(); return; diff --git a/shared/js/ui/modal/ModalSettings.tsx b/shared/js/ui/modal/ModalSettings.tsx index 2dc8382c..c87b8517 100644 --- a/shared/js/ui/modal/ModalSettings.tsx +++ b/shared/js/ui/modal/ModalSettings.tsx @@ -25,6 +25,7 @@ import * as ReactDOM from "react-dom"; import {NotificationSettings} from "tc-shared/ui/modal/settings/Notifications"; import {initialize_audio_microphone_controller, MicrophoneSettingsEvents} from "tc-shared/ui/modal/settings/Microphone"; import {MicrophoneSettings} from "tc-shared/ui/modal/settings/MicrophoneRenderer"; +import {getBackend} from "tc-shared/backend"; type ProfileInfoEvent = { id: string, @@ -486,7 +487,7 @@ function settings_general_language(container: JQuery, modal: Modal) { if (__build.target === "web") { location.reload(); } else { - createErrorModal(tr("Not implemented"), tr("Client restart isn't implemented.
Please do it manually!")).open(); + getBackend("native").reloadWindow(); } }); @@ -629,7 +630,7 @@ function settings_audio_speaker(container: JQuery, modal: Modal) { const current_selected = getAudioBackend().getCurrentDevice(); const generate_device = (device: OutputDevice | undefined) => { - const selected = device === current_selected || (typeof (current_selected) !== "undefined" && typeof (device) !== "undefined" && current_selected.device_id == device.device_id); + const selected = device === current_selected || (typeof (current_selected) !== "undefined" && typeof (device) !== "undefined" && current_selected.deviceId == device.deviceId); const tag = $.spawn("div").addClass("device").toggleClass("selected", selected).append( $.spawn("div").addClass("container-selected").append( @@ -653,7 +654,7 @@ function settings_audio_speaker(container: JQuery, modal: Modal) { _old.removeClass("selected"); tag.addClass("selected"); - const targetDeviceId = device.device_id || OutputDevice.NoDeviceId; + const targetDeviceId = device.deviceId || OutputDevice.NoDeviceId; getAudioBackend().setCurrentDevice(targetDeviceId).then(() => { logDebug(LogCategory.AUDIO, tr("Changed default speaker device")); settings.setValue(Settings.KEY_SPEAKER_DEVICE_ID, targetDeviceId); diff --git a/web/app/audio/Player.ts b/web/app/audio/Player.ts index 45d0c35f..3b729092 100644 --- a/web/app/audio/Player.ts +++ b/web/app/audio/Player.ts @@ -4,7 +4,7 @@ import {tr} from "tc-shared/i18n/localize"; import {Registry} from "tc-events"; const kWebDevice: OutputDevice = { - device_id: "default", + deviceId: "default", name: "default playback", driver: 'Web Audio' }; @@ -59,7 +59,7 @@ export class WebAudioBackend implements AudioBackend { } getDefaultDeviceId(): string { - return kWebDevice.device_id; + return kWebDevice.deviceId; } getMasterVolume(): number {