diff --git a/src/voice-broadcast/components/molecules/VoiceBroadcastPreRecordingPip.tsx b/src/voice-broadcast/components/molecules/VoiceBroadcastPreRecordingPip.tsx index ff3ff675c0e..12972dc93e7 100644 --- a/src/voice-broadcast/components/molecules/VoiceBroadcastPreRecordingPip.tsx +++ b/src/voice-broadcast/components/molecules/VoiceBroadcastPreRecordingPip.tsx @@ -28,33 +28,19 @@ interface Props { voiceBroadcastPreRecording: VoiceBroadcastPreRecording; } -interface State { - showDeviceSelect: boolean; - disableStartButton: boolean; -} - export const VoiceBroadcastPreRecordingPip: React.FC = ({ voiceBroadcastPreRecording }) => { const pipRef = useRef(null); const { currentDevice, currentDeviceLabel, devices, setDevice } = useAudioDeviceSelection(); - const [state, setState] = useState({ - showDeviceSelect: false, - disableStartButton: false, - }); + const [disableStartButton, setDisableStartButton] = useState(false); + const [showDeviceSelect, setShowDeviceSelect] = useState(false); const onDeviceSelect = (device: MediaDeviceInfo): void => { - setState((state) => ({ - ...state, - showDeviceSelect: false, - })); + setShowDeviceSelect(() => false); setDevice(device); }; const onStartBroadcastClick = (): void => { - setState((state) => ({ - ...state, - disableStartButton: true, - })); - + setDisableStartButton(() => true); voiceBroadcastPreRecording.start(); }; @@ -63,7 +49,7 @@ export const VoiceBroadcastPreRecordingPip: React.FC = ({ voiceBroadcastP setState({ ...state, showDeviceSelect: true })} + onMicrophoneLineClick={(): void => setShowDeviceSelect(() => true)} room={voiceBroadcastPreRecording.room} microphoneLabel={currentDeviceLabel} showClose={true} @@ -72,12 +58,12 @@ export const VoiceBroadcastPreRecordingPip: React.FC = ({ voiceBroadcastP className="mx_VoiceBroadcastBody_blockButton" kind="danger" onClick={onStartBroadcastClick} - disabled={state.disableStartButton} + disabled={disableStartButton} > {_t("Go live")} - {state.showDeviceSelect && ( + {showDeviceSelect && ( { }); }); - it("should call start once", () => { + it("should dissable the button and call start once", () => { + expect(screen.getByText("Go live")).toHaveAttribute("disabled"); expect(preRecording.start).toHaveBeenCalledTimes(1); }); });