From d08962a610628951dbb52781d79cc4feac07c175 Mon Sep 17 00:00:00 2001 From: Sara Date: Wed, 4 Oct 2023 15:45:21 +0200 Subject: [PATCH] hides mic switch the right way --- www/app/transcripts/audioInputsDropdown.tsx | 16 +++------------- www/app/transcripts/recorder.tsx | 5 +++-- 2 files changed, 6 insertions(+), 15 deletions(-) diff --git a/www/app/transcripts/audioInputsDropdown.tsx b/www/app/transcripts/audioInputsDropdown.tsx index 7772358b..56204286 100644 --- a/www/app/transcripts/audioInputsDropdown.tsx +++ b/www/app/transcripts/audioInputsDropdown.tsx @@ -6,19 +6,9 @@ const AudioInputsDropdown: React.FC<{ audioDevices: Option[]; disabled: boolean; hide: () => void; + deviceId: string; setDeviceId: React.Dispatch>; }> = (props) => { - const [ddOptions, setDdOptions] = useState([]); - - useEffect(() => { - if (props.audioDevices) { - setDdOptions(props.audioDevices); - props.setDeviceId( - props.audioDevices.length > 0 ? props.audioDevices[0].value : null, - ); - } - }, [props.audioDevices]); - const handleDropdownChange = (option: Option) => { props.setDeviceId(option.value); props.hide(); @@ -26,9 +16,9 @@ const AudioInputsDropdown: React.FC<{ return ( diff --git a/www/app/transcripts/recorder.tsx b/www/app/transcripts/recorder.tsx index f93e10d4..ed86a73f 100644 --- a/www/app/transcripts/recorder.tsx +++ b/www/app/transcripts/recorder.tsx @@ -279,7 +279,7 @@ export default function Recorder(props: RecorderProps) { useEffect(() => { if (props.audioDevices && props.audioDevices.length > 0) { - setDeviceId[props.audioDevices[0].value]; + setDeviceId(props.audioDevices[0].value); } }, [props.audioDevices]); @@ -347,7 +347,7 @@ export default function Recorder(props: RecorderProps) { > {isRecording ? "Stop" : "Record"} - {props.audioDevices && props.audioDevices?.length > 0 && ( + {props.audioDevices && props.audioDevices?.length > 0 && deviceId && ( <>