Renamed device_id to deviceId

master
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 {
device_id: string;
deviceId: string;
driver: string;
name: string;

View File

@ -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<ControlBarEvents
if(typeof event.targetDeviceId === "string") {
try {
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) {
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;

View File

@ -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.<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 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);

View File

@ -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 {