From 3736218c41cfdaf55fc4ca84b9053d9a49675fcf Mon Sep 17 00:00:00 2001 From: xdzqyyds <2292136545@qq.com> Date: Sat, 23 Nov 2024 18:54:07 +0800 Subject: [PATCH] fix video screen label --- webapp/components/device.tsx | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/webapp/components/device.tsx b/webapp/components/device.tsx index 57dec1e..3296b4a 100644 --- a/webapp/components/device.tsx +++ b/webapp/components/device.tsx @@ -35,7 +35,7 @@ export default function DeviceBar(props: { streamId: string }) { const [currentDeviceSpeaker, setCurrentDeviceSpeaker] = useAtom(deviceSpeakerAtom) const [SpeakerStatus, setSpeakerStatus] = useAtom(SpeakerStatusAtom) - const [mobileDevice, setMobileDevice] = useState(false) + const [mobileDevice, setMobileDevice] = useState(null) const { userStatus, @@ -113,7 +113,7 @@ export default function DeviceBar(props: { streamId: string }) { setDeviceSpeaker([...speakers]) setDeviceAudio([...audios]) - setDeviceVideo([...videos, deviceScreen]) + setDeviceVideo(mobileDevice ? [...videos] : [...videos, deviceScreen]) } const init = async () => { @@ -138,8 +138,11 @@ export default function DeviceBar(props: { streamId: string }) { } useEffect(() => { + if (mobileDevice === null) { + return + } init() - }, []) + }, [mobileDevice]) useEffect(() => { // Reference: https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/devicechange_event