MCPcopy
hub / github.com/RocketChat/Rocket.Chat / DevicePicker

Function DevicePicker

packages/ui-voip/src/components/DevicePicker.tsx:39–156  ·  view source on GitHub ↗
({ secondary = false, className }: { secondary?: boolean; className?: string })

Source from the content-addressed store, hash-verified

37
38// eslint-disable-next-line react/no-multi-comp
39const DevicePicker = ({ secondary = false, className }: { secondary?: boolean; className?: string }) => {
40 const { t } = useTranslation();
41
42 const { onDeviceChange } = useMediaCallView();
43
44 const availableDevices = useAvailableDevices();
45 const selectedAudioDevices = useSelectedDevices();
46
47 const availableInputDevice =
48 availableDevices?.audioInput?.map<GenericMenuItemProps>((device) => {
49 if (!device.id || !device.label) {
50 return getDefaultDeviceItem(t('Default'), 'input');
51 }
52
53 return {
54 id: `${device.id}-input`,
55 content: (
56 <Box is='span' title={device.label} fontSize={14}>
57 {device.label}
58 </Box>
59 ),
60 addon: <RadioButton checked={device.id === selectedAudioDevices?.audioInput?.id} />,
61 };
62 }) || [];
63
64 const availableOutputDevice =
65 availableDevices?.audioOutput?.map<GenericMenuItemProps>((device) => {
66 if (!device.id || !device.label) {
67 return getDefaultDeviceItem(t('Default'), 'output');
68 }
69
70 return {
71 id: `${device.id}-output`,
72 content: (
73 <Box is='span' title={device.label} fontSize={14}>
74 {device.label}
75 </Box>
76 ),
77 addon: <RadioButton checked={device.id === selectedAudioDevices?.audioOutput?.id} />,
78 onClick(e?: MouseEvent<HTMLElement>) {
79 e?.preventDefault();
80 e?.stopPropagation();
81 },
82 };
83 }) || [];
84
85 const micSection = {
86 title: t('Microphone'),
87 items: availableInputDevice,
88 };
89
90 const speakerSection = {
91 title: t('Speaker'),
92 items: availableOutputDevice,
93 };
94
95 const disabled = availableOutputDevice.length === 0 && availableInputDevice.length === 0;
96

Callers

nothing calls this directly

Calls 13

useMediaCallViewFunction · 0.90
useAvailableDevicesFunction · 0.90
useSelectedDevicesFunction · 0.90
stopTracksFunction · 0.90
useTranslationFunction · 0.85
getDefaultDeviceItemFunction · 0.85
tFunction · 0.85
replaceMethod · 0.80
findMethod · 0.65
warnMethod · 0.65
onDeviceChangeFunction · 0.50

Tested by

no test coverage detected