({ secondary = false, className }: { secondary?: boolean; className?: string })
| 37 | |
| 38 | // eslint-disable-next-line react/no-multi-comp |
| 39 | const 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 |
nothing calls this directly
no test coverage detected