mirror of
https://github.com/vector-im/element-call.git
synced 2026-08-29 21:15:19 +00:00
no useMediaDeviceNames
This commit is contained in:
@@ -124,7 +124,7 @@ function useMediaDeviceHandle(
|
|||||||
usingNames: boolean,
|
usingNames: boolean,
|
||||||
): MediaDeviceHandle {
|
): MediaDeviceHandle {
|
||||||
const hasRequestedPermissions = useRef(false);
|
const hasRequestedPermissions = useRef(false);
|
||||||
const requestPermissions = usingNames || hasRequestedPermissions.current;
|
// const requestPermissions = usingNames || hasRequestedPermissions.current;
|
||||||
// Make sure we don't needlessly reset to a device observer without names,
|
// Make sure we don't needlessly reset to a device observer without names,
|
||||||
// once permissions are already given
|
// once permissions are already given
|
||||||
hasRequestedPermissions.current ||= usingNames;
|
hasRequestedPermissions.current ||= usingNames;
|
||||||
@@ -140,7 +140,7 @@ function useMediaDeviceHandle(
|
|||||||
createMediaDeviceObserver(
|
createMediaDeviceObserver(
|
||||||
kind,
|
kind,
|
||||||
() => logger.error("Error creating MediaDeviceObserver"),
|
() => logger.error("Error creating MediaDeviceObserver"),
|
||||||
requestPermissions,
|
true,
|
||||||
).pipe(
|
).pipe(
|
||||||
startWith([]),
|
startWith([]),
|
||||||
// This Observable emits new values whenever the browser fires a
|
// This Observable emits new values whenever the browser fires a
|
||||||
@@ -151,7 +151,7 @@ function useMediaDeviceHandle(
|
|||||||
// we call MediaDevices.getUserMedia. So, filter by deep equality.
|
// we call MediaDevices.getUserMedia. So, filter by deep equality.
|
||||||
distinctUntilChanged<MediaDeviceInfo[]>(deepCompare),
|
distinctUntilChanged<MediaDeviceInfo[]>(deepCompare),
|
||||||
),
|
),
|
||||||
[kind, requestPermissions],
|
[kind],
|
||||||
);
|
);
|
||||||
const available = useObservableEagerState(
|
const available = useObservableEagerState(
|
||||||
useMemo(
|
useMemo(
|
||||||
@@ -400,23 +400,6 @@ function useControlledOutput(): MediaDeviceHandle {
|
|||||||
export const useMediaDevices = (): MediaDevices =>
|
export const useMediaDevices = (): MediaDevices =>
|
||||||
useContext(MediaDevicesContext);
|
useContext(MediaDevicesContext);
|
||||||
|
|
||||||
/**
|
|
||||||
* React hook that requests for the media devices context to be populated with
|
|
||||||
* real device names while this component is mounted. This is not done by
|
|
||||||
* default because it may involve requesting additional permissions from the
|
|
||||||
* user.
|
|
||||||
*/
|
|
||||||
export const useMediaDeviceNames = (
|
|
||||||
context: MediaDevices,
|
|
||||||
enabled = true,
|
|
||||||
): void =>
|
|
||||||
useEffect(() => {
|
|
||||||
if (enabled) {
|
|
||||||
context.startUsingDeviceNames();
|
|
||||||
return context.stopUsingDeviceNames;
|
|
||||||
}
|
|
||||||
}, [context, enabled]);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A convenience hook to get the audio node configuration for the earpiece.
|
* A convenience hook to get the audio node configuration for the earpiece.
|
||||||
* It will check the `useAsEarpiece` of the `audioOutput` device and return
|
* It will check the `useAsEarpiece` of the `audioOutput` device and return
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ import { ProfileSettingsTab } from "./ProfileSettingsTab";
|
|||||||
import { FeedbackSettingsTab } from "./FeedbackSettingsTab";
|
import { FeedbackSettingsTab } from "./FeedbackSettingsTab";
|
||||||
import {
|
import {
|
||||||
useMediaDevices,
|
useMediaDevices,
|
||||||
useMediaDeviceNames,
|
|
||||||
iosDeviceMenu$,
|
iosDeviceMenu$,
|
||||||
} from "../livekit/MediaDevicesContext";
|
} from "../livekit/MediaDevicesContext";
|
||||||
import { widget } from "../widget";
|
import { widget } from "../widget";
|
||||||
@@ -98,7 +97,6 @@ export const SettingsModal: FC<Props> = ({
|
|||||||
};
|
};
|
||||||
|
|
||||||
const devices = useMediaDevices();
|
const devices = useMediaDevices();
|
||||||
useMediaDeviceNames(devices, open);
|
|
||||||
const [soundVolume, setSoundVolume] = useSetting(soundEffectVolumeSetting);
|
const [soundVolume, setSoundVolume] = useSetting(soundEffectVolumeSetting);
|
||||||
const [soundVolumeRaw, setSoundVolumeRaw] = useState(soundVolume);
|
const [soundVolumeRaw, setSoundVolumeRaw] = useState(soundVolume);
|
||||||
const [showDeveloperSettingsTab] = useSetting(developerMode);
|
const [showDeveloperSettingsTab] = useSetting(developerMode);
|
||||||
|
|||||||
Reference in New Issue
Block a user