From 8b37003828108fa334658ebd8b87f183018250b2 Mon Sep 17 00:00:00 2001 From: winter_NaN Date: Wed, 27 Nov 2024 21:33:09 +0800 Subject: [PATCH] fix unreasonable room user information status --- webapp/components/layout.tsx | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/webapp/components/layout.tsx b/webapp/components/layout.tsx index 6a20e16..7bc0793 100644 --- a/webapp/components/layout.tsx +++ b/webapp/components/layout.tsx @@ -46,6 +46,19 @@ export default function Layout(props: { meetingId: string }) { setMeetingJoined(false) } + useEffect(() => { + const cleanup = () => { + delStream(props.meetingId, localStreamId) + } + // Need to set separate Browser Events Parameters for Firefox refresh and browser termination + window.addEventListener('beforeunload', cleanup) // Used to monitor the browser termination of Firefox event + window.addEventListener('unload', cleanup) // Used to monitor Firefox refresh event + return () => { + window.removeEventListener('beforeunload', cleanup) + window.removeEventListener('unload', cleanup) + } + }, [props.meetingId, localStreamId]) + //useEffect(() => { // let shareScreenId = "" // const setShareScreenId = (id: string) => shareScreenId = id