Renamed device_id to deviceId

This commit is contained in:
WolverinDEV 2021-03-25 12:35:59 +01:00
parent 687054e07c
commit e1e98b07d5
4 changed files with 14 additions and 13 deletions

View file

@ -1,5 +1,5 @@
export interface OutputDevice { export interface OutputDevice {
device_id: string; deviceId: string;
driver: string; driver: string;
name: string; name: string;

View file

@ -310,15 +310,15 @@ class InfoController {
} }
const devices = await backend.getAvailableDevices(); const devices = await backend.getAvailableDevices();
const selectedDeviceId = backend.getCurrentDevice()?.device_id; const selectedDeviceId = backend.getCurrentDevice()?.deviceId;
const defaultDeviceId = backend.getDefaultDeviceId(); const defaultDeviceId = backend.getDefaultDeviceId();
this.events.fire_react("notify_speaker_list", { this.events.fire_react("notify_speaker_list", {
state: "initialized", state: "initialized",
devices: devices.map(device => { devices: devices.map(device => {
let selected = false; let selected = false;
if(selectedDeviceId === OutputDevice.DefaultDeviceId && device.device_id === defaultDeviceId) { if(selectedDeviceId === OutputDevice.DefaultDeviceId && device.deviceId === defaultDeviceId) {
selected = true; selected = true;
} else if(selectedDeviceId === device.device_id) { } else if(selectedDeviceId === device.deviceId) {
selected = true; selected = true;
} }
@ -326,7 +326,7 @@ class InfoController {
name: device.name, name: device.name,
driver: device.driver, driver: device.driver,
id: device.device_id, id: device.deviceId,
selected: selected selected: selected
} }
}) })
@ -513,13 +513,13 @@ export function initializeControlBarController(events: Registry<ControlBarEvents
if(typeof event.targetDeviceId === "string") { if(typeof event.targetDeviceId === "string") {
try { try {
const devices = await getAudioBackend().getAvailableDevices(); const devices = await getAudioBackend().getAvailableDevices();
const device = devices.find(device => device.device_id === event.targetDeviceId); const device = devices.find(device => device.deviceId === event.targetDeviceId);
if(!device) { if(!device) {
throw tr("Target device could not be found."); throw tr("Target device could not be found.");
} }
await getAudioBackend().setCurrentDevice(device.device_id); await getAudioBackend().setCurrentDevice(device.deviceId);
settings.setValue(Settings.KEY_SPEAKER_DEVICE_ID, device.device_id); settings.setValue(Settings.KEY_SPEAKER_DEVICE_ID, device.deviceId);
} catch (error) { } catch (error) {
createErrorModal(tr("Failed to change speaker"), tr("Failed to change speaker.\nTarget device could not be found.")).open(); createErrorModal(tr("Failed to change speaker"), tr("Failed to change speaker.\nTarget device could not be found.")).open();
return; return;

View file

@ -25,6 +25,7 @@ import * as ReactDOM from "react-dom";
import {NotificationSettings} from "tc-shared/ui/modal/settings/Notifications"; import {NotificationSettings} from "tc-shared/ui/modal/settings/Notifications";
import {initialize_audio_microphone_controller, MicrophoneSettingsEvents} from "tc-shared/ui/modal/settings/Microphone"; import {initialize_audio_microphone_controller, MicrophoneSettingsEvents} from "tc-shared/ui/modal/settings/Microphone";
import {MicrophoneSettings} from "tc-shared/ui/modal/settings/MicrophoneRenderer"; import {MicrophoneSettings} from "tc-shared/ui/modal/settings/MicrophoneRenderer";
import {getBackend} from "tc-shared/backend";
type ProfileInfoEvent = { type ProfileInfoEvent = {
id: string, id: string,
@ -486,7 +487,7 @@ function settings_general_language(container: JQuery, modal: Modal) {
if (__build.target === "web") { if (__build.target === "web") {
location.reload(); location.reload();
} else { } else {
createErrorModal(tr("Not implemented"), tr("Client restart isn't implemented.<br>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 current_selected = getAudioBackend().getCurrentDevice();
const generate_device = (device: OutputDevice | undefined) => { 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( const tag = $.spawn("div").addClass("device").toggleClass("selected", selected).append(
$.spawn("div").addClass("container-selected").append( $.spawn("div").addClass("container-selected").append(
@ -653,7 +654,7 @@ function settings_audio_speaker(container: JQuery, modal: Modal) {
_old.removeClass("selected"); _old.removeClass("selected");
tag.addClass("selected"); tag.addClass("selected");
const targetDeviceId = device.device_id || OutputDevice.NoDeviceId; const targetDeviceId = device.deviceId || OutputDevice.NoDeviceId;
getAudioBackend().setCurrentDevice(targetDeviceId).then(() => { getAudioBackend().setCurrentDevice(targetDeviceId).then(() => {
logDebug(LogCategory.AUDIO, tr("Changed default speaker device")); logDebug(LogCategory.AUDIO, tr("Changed default speaker device"));
settings.setValue(Settings.KEY_SPEAKER_DEVICE_ID, targetDeviceId); settings.setValue(Settings.KEY_SPEAKER_DEVICE_ID, targetDeviceId);

View file

@ -4,7 +4,7 @@ import {tr} from "tc-shared/i18n/localize";
import {Registry} from "tc-events"; import {Registry} from "tc-events";
const kWebDevice: OutputDevice = { const kWebDevice: OutputDevice = {
device_id: "default", deviceId: "default",
name: "default playback", name: "default playback",
driver: 'Web Audio' driver: 'Web Audio'
}; };
@ -59,7 +59,7 @@ export class WebAudioBackend implements AudioBackend {
} }
getDefaultDeviceId(): string { getDefaultDeviceId(): string {
return kWebDevice.device_id; return kWebDevice.deviceId;
} }
getMasterVolume(): number { getMasterVolume(): number {