Remove dead code
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
This commit is contained in:
parent
102b79e518
commit
c209553dc1
3 changed files with 1 additions and 122 deletions
|
@ -1,45 +0,0 @@
|
||||||
/*
|
|
||||||
Copyright 2024 New Vector Ltd.
|
|
||||||
Copyright 2022, 2023 The Matrix.org Foundation C.I.C.
|
|
||||||
|
|
||||||
SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only
|
|
||||||
Please see LICENSE files in the repository root for full details.
|
|
||||||
*/
|
|
||||||
|
|
||||||
import React, { MutableRefObject } from "react";
|
|
||||||
|
|
||||||
import { toLeftOrRightOf } from "../../structures/ContextMenu";
|
|
||||||
import IconizedContextMenu, {
|
|
||||||
IconizedContextMenuOptionList,
|
|
||||||
IconizedContextMenuRadio,
|
|
||||||
} from "../context_menus/IconizedContextMenu";
|
|
||||||
|
|
||||||
interface Props {
|
|
||||||
containerRef: MutableRefObject<HTMLElement | null>;
|
|
||||||
currentDevice: MediaDeviceInfo | null;
|
|
||||||
devices: MediaDeviceInfo[];
|
|
||||||
onDeviceSelect: (device: MediaDeviceInfo) => void;
|
|
||||||
}
|
|
||||||
|
|
||||||
export const DevicesContextMenu: React.FC<Props> = ({ containerRef, currentDevice, devices, onDeviceSelect }) => {
|
|
||||||
const deviceOptions = devices.map((d: MediaDeviceInfo) => {
|
|
||||||
return (
|
|
||||||
<IconizedContextMenuRadio
|
|
||||||
key={d.deviceId}
|
|
||||||
active={d.deviceId === currentDevice?.deviceId}
|
|
||||||
onClick={() => onDeviceSelect(d)}
|
|
||||||
label={d.label}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
return (
|
|
||||||
<IconizedContextMenu
|
|
||||||
mountAsChild={false}
|
|
||||||
onFinished={() => {}}
|
|
||||||
{...(containerRef.current ? toLeftOrRightOf(containerRef.current.getBoundingClientRect(), 0) : {})}
|
|
||||||
>
|
|
||||||
<IconizedContextMenuOptionList>{deviceOptions}</IconizedContextMenuOptionList>
|
|
||||||
</IconizedContextMenu>
|
|
||||||
);
|
|
||||||
};
|
|
|
@ -72,7 +72,7 @@ export const contextMenuBelow = (elementRect: PartialDOMRect): MenuProps => {
|
||||||
return { left, top, chevronFace };
|
return { left, top, chevronFace };
|
||||||
};
|
};
|
||||||
|
|
||||||
export class RoomTile extends React.PureComponent<Props, State> {
|
class RoomTile extends React.PureComponent<Props, State> {
|
||||||
private dispatcherRef?: string;
|
private dispatcherRef?: string;
|
||||||
private roomTileRef = createRef<HTMLDivElement>();
|
private roomTileRef = createRef<HTMLDivElement>();
|
||||||
private notificationState: NotificationState;
|
private notificationState: NotificationState;
|
||||||
|
|
|
@ -1,76 +0,0 @@
|
||||||
/*
|
|
||||||
Copyright 2024 New Vector Ltd.
|
|
||||||
Copyright 2022 The Matrix.org Foundation C.I.C.
|
|
||||||
|
|
||||||
SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only
|
|
||||||
Please see LICENSE files in the repository root for full details.
|
|
||||||
*/
|
|
||||||
|
|
||||||
import { useRef, useState } from "react";
|
|
||||||
|
|
||||||
import { _t } from "../languageHandler";
|
|
||||||
import MediaDeviceHandler, { MediaDeviceKindEnum } from "../MediaDeviceHandler";
|
|
||||||
import { requestMediaPermissions } from "../utils/media/requestMediaPermissions";
|
|
||||||
|
|
||||||
interface State {
|
|
||||||
devices: MediaDeviceInfo[];
|
|
||||||
device: MediaDeviceInfo | null;
|
|
||||||
}
|
|
||||||
|
|
||||||
export const useAudioDeviceSelection = (
|
|
||||||
onDeviceChanged?: (device: MediaDeviceInfo) => void,
|
|
||||||
): {
|
|
||||||
currentDevice: MediaDeviceInfo | null;
|
|
||||||
currentDeviceLabel: string;
|
|
||||||
devices: MediaDeviceInfo[];
|
|
||||||
setDevice(device: MediaDeviceInfo): void;
|
|
||||||
} => {
|
|
||||||
const shouldRequestPermissionsRef = useRef<boolean>(true);
|
|
||||||
const [state, setState] = useState<State>({
|
|
||||||
devices: [],
|
|
||||||
device: null,
|
|
||||||
});
|
|
||||||
|
|
||||||
if (shouldRequestPermissionsRef.current) {
|
|
||||||
shouldRequestPermissionsRef.current = false;
|
|
||||||
requestMediaPermissions(false).then((stream: MediaStream | undefined) => {
|
|
||||||
MediaDeviceHandler.getDevices().then((devices) => {
|
|
||||||
if (!devices) return;
|
|
||||||
const { audioinput } = devices;
|
|
||||||
MediaDeviceHandler.getDefaultDevice(audioinput);
|
|
||||||
const deviceFromSettings = MediaDeviceHandler.getAudioInput();
|
|
||||||
const device =
|
|
||||||
audioinput.find((d) => {
|
|
||||||
return d.deviceId === deviceFromSettings;
|
|
||||||
}) || audioinput[0];
|
|
||||||
setState({
|
|
||||||
...state,
|
|
||||||
devices: audioinput,
|
|
||||||
device,
|
|
||||||
});
|
|
||||||
stream?.getTracks().forEach((t) => t.stop());
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
const setDevice = (device: MediaDeviceInfo): void => {
|
|
||||||
const shouldNotify = device.deviceId !== state.device?.deviceId;
|
|
||||||
MediaDeviceHandler.instance.setDevice(device.deviceId, MediaDeviceKindEnum.AudioInput);
|
|
||||||
|
|
||||||
setState({
|
|
||||||
...state,
|
|
||||||
device,
|
|
||||||
});
|
|
||||||
|
|
||||||
if (shouldNotify) {
|
|
||||||
onDeviceChanged?.(device);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
return {
|
|
||||||
currentDevice: state.device,
|
|
||||||
currentDeviceLabel: state.device?.label || _t("voip|default_device"),
|
|
||||||
devices: state.devices,
|
|
||||||
setDevice,
|
|
||||||
};
|
|
||||||
};
|
|
Loading…
Add table
Add a link
Reference in a new issue