Skip to content

Commit

Permalink
fix(microphoneCheckPage): fix device check logic (#538)
Browse files Browse the repository at this point in the history
  • Loading branch information
Cheerego7 committed Apr 15, 2021
1 parent d96c337 commit bed7047
Showing 1 changed file with 9 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,6 @@ interface SpeakerVolumeProps {
percent: number;
}

export enum TestingResult {
Undefined = -1,
Success = 0,
Fail = 1,
}

const SpeakerVolume = observer<SpeakerVolumeProps>(function SpeakerVolume({ percent }) {
return (
<div className="speaker-audio-wrapper">
Expand All @@ -42,6 +36,15 @@ export const MicrophoneCheckPage = (): React.ReactElement => {
const location = useLocation<DeviceCheckResults | undefined>();
const history = useHistory<DeviceCheckResults>();

const { systemCheck, cameraCheck, speakerCheck } = location.state || {};

const isSuccess =
// also checked undefined
systemCheck?.hasError === false &&
cameraCheck?.hasError === false &&
speakerCheck?.hasError === false &&
micCheckState?.hasError === false;

useEffect(() => {
setDevices(rtcEngine.getAudioRecordingDevices() as Device[]);

Expand Down Expand Up @@ -149,14 +152,6 @@ export const MicrophoneCheckPage = (): React.ReactElement => {
}

function renderTitle(): React.ReactNode {
const { systemCheck, cameraCheck, speakerCheck } = location.state || {};

const isSuccess =
!systemCheck?.hasError &&
!cameraCheck?.hasError &&
!speakerCheck?.hasError &&
!micCheckState?.hasError;

if (isSuccess) {
return (
<div className="device-check-modal-title">
Expand All @@ -175,13 +170,6 @@ export const MicrophoneCheckPage = (): React.ReactElement => {
}

function renderFooter(): React.ReactNode {
const { systemCheck, cameraCheck, speakerCheck } = location.state || {};
const isSuccess =
!systemCheck?.hasError &&
!cameraCheck?.hasError &&
!speakerCheck?.hasError &&
!micCheckState?.hasError;

if (!isSuccess) {
return (
<Button type="primary" onClick={resetCheck} className="device-check-modal-btn">
Expand Down

0 comments on commit bed7047

Please sign in to comment.