mirror of
https://github.com/vector-im/element-call.git
synced 2026-03-16 06:17:10 +00:00
change label on button
This commit is contained in:
@@ -322,43 +322,42 @@ export const MediaDevicesProvider: FC<Props> = ({ children }) => {
|
||||
};
|
||||
|
||||
function useControlledOutput(): MediaDeviceHandle {
|
||||
const { available, deviceForEarpiece: physicalDeviceForEarpiceMode } =
|
||||
useObservableEagerState(
|
||||
useObservable(() => {
|
||||
const outputDeviceData$ = setAvailableOutputDevices$.pipe(
|
||||
startWith<OutputDevice[]>([]),
|
||||
map((devices) => {
|
||||
const deviceForEarpiece = devices.find((d) => d.forEarpiece);
|
||||
const deviceMapTuple: [string, DeviceLabel][] = devices.map(
|
||||
({ id, name, isEarpiece, isSpeaker /*,isExternalHeadset*/ }) => {
|
||||
let deviceLabel: DeviceLabel = { type: "name", name };
|
||||
// if (isExternalHeadset) // Do we want this?
|
||||
if (isEarpiece) deviceLabel = { type: "earpiece" };
|
||||
if (isSpeaker) deviceLabel = { type: "default", name };
|
||||
return [id, deviceLabel];
|
||||
},
|
||||
);
|
||||
return {
|
||||
devicesMap: new Map<string, DeviceLabel>(deviceMapTuple),
|
||||
deviceForEarpiece,
|
||||
};
|
||||
}),
|
||||
);
|
||||
const { available } = useObservableEagerState(
|
||||
useObservable(() => {
|
||||
const outputDeviceData$ = setAvailableOutputDevices$.pipe(
|
||||
startWith<OutputDevice[]>([]),
|
||||
map((devices) => {
|
||||
const deviceForEarpiece = devices.find((d) => d.forEarpiece);
|
||||
const deviceMapTuple: [string, DeviceLabel][] = devices.map(
|
||||
({ id, name, isEarpiece, isSpeaker /*,isExternalHeadset*/ }) => {
|
||||
let deviceLabel: DeviceLabel = { type: "name", name };
|
||||
// if (isExternalHeadset) // Do we want this?
|
||||
if (isEarpiece) deviceLabel = { type: "earpiece" };
|
||||
if (isSpeaker) deviceLabel = { type: "default", name };
|
||||
return [id, deviceLabel];
|
||||
},
|
||||
);
|
||||
return {
|
||||
devicesMap: new Map<string, DeviceLabel>(deviceMapTuple),
|
||||
deviceForEarpiece,
|
||||
};
|
||||
}),
|
||||
);
|
||||
|
||||
return combineLatest([outputDeviceData$, iosDeviceMenu$]).pipe(
|
||||
map(([{ devicesMap, deviceForEarpiece }, iosShowEarpiece]) => {
|
||||
let available = devicesMap;
|
||||
if (iosShowEarpiece && !!deviceForEarpiece) {
|
||||
available = new Map([
|
||||
...devicesMap.entries(),
|
||||
[EARPIECE_CONFIG_ID, { type: "earpiece" }],
|
||||
]);
|
||||
}
|
||||
return { available, deviceForEarpiece };
|
||||
}),
|
||||
);
|
||||
}),
|
||||
);
|
||||
return combineLatest([outputDeviceData$, iosDeviceMenu$]).pipe(
|
||||
map(([{ devicesMap, deviceForEarpiece }, iosShowEarpiece]) => {
|
||||
let available = devicesMap;
|
||||
if (iosShowEarpiece && !!deviceForEarpiece) {
|
||||
available = new Map([
|
||||
...devicesMap.entries(),
|
||||
[EARPIECE_CONFIG_ID, { type: "earpiece" }],
|
||||
]);
|
||||
}
|
||||
return { available, deviceForEarpiece };
|
||||
}),
|
||||
);
|
||||
}),
|
||||
);
|
||||
const [preferredId, setPreferredId] = useSetting(audioOutputSetting);
|
||||
useEffect(() => {
|
||||
setOutputDevice$.subscribe((id) => {
|
||||
|
||||
@@ -11,7 +11,7 @@ import { type MatrixClient } from "matrix-js-sdk";
|
||||
import { Button, Root as Form, Separator } from "@vector-im/compound-web";
|
||||
import { type Room as LivekitRoom } from "livekit-client";
|
||||
import { useObservableEagerState } from "observable-hooks";
|
||||
// import { logger } from "matrix-js-sdk/lib/logger";
|
||||
import { logger } from "matrix-js-sdk/lib/logger";
|
||||
|
||||
import { Modal } from "../Modal";
|
||||
import styles from "./SettingsModal.module.css";
|
||||
@@ -128,12 +128,12 @@ export const SettingsModal: FC<Props> = ({
|
||||
{iosDeviceMenu && (
|
||||
<Button
|
||||
kind="secondary"
|
||||
// onClick={(): void => {
|
||||
// logger.log("Open native device picker");
|
||||
// // window.controls.showNativeOutputDevicePicker?.();
|
||||
// }}
|
||||
onClick={(): void => {
|
||||
logger.log("Open native device picker");
|
||||
window.controls.showNativeOutputDevicePicker?.();
|
||||
}}
|
||||
>
|
||||
{t("settings.devices.change_device_button")}
|
||||
Test
|
||||
</Button>
|
||||
)}
|
||||
<DeviceSelection
|
||||
|
||||
Reference in New Issue
Block a user