Skip to content

Commit

Permalink
fix unreasonable room user information status (#27)
Browse files Browse the repository at this point in the history
* fix unreasonable room user information status

* fix(webapp): api delStream keeplive

---------

Co-authored-by: a-wing <[email protected]>
  • Loading branch information
WinterJack002 and a-wing authored Nov 28, 2024
1 parent 24da6a6 commit 409ad2a
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
23 changes: 23 additions & 0 deletions webapp/components/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,29 @@ export default function Layout(props: { meetingId: string }) {
setMeetingJoined(false)
}

useEffect(() => {
const cleanup = () => {
delStream(props.meetingId, localStreamId)
}
// NOTE:
// https://github.com/binbat/woom/pull/27
// https://developer.mozilla.org/en-US/docs/Web/API/Window/unload_event
// `unload` event is Deprecated, But Firefox need `unload`
//
// event | Chrome | Firefox | Safari
// ---------------------------- | ------------------------- | ------------------------- | -----
// `beforeunload` | ok | console error, no request | console error, request ok
// `unload` | console error, no request | ok | console no request log, no request
// `beforeunload` + `keepalive` | ok | console error, no request | console error, request ok
// `unload` + `keepalive` | console error, request ok | ok | console no request log, request ok
window.addEventListener('beforeunload', cleanup)
window.addEventListener('unload', cleanup)
return () => {
window.removeEventListener('beforeunload', cleanup)
window.removeEventListener('unload', cleanup)
}
}, [props.meetingId, localStreamId])

//useEffect(() => {
// let shareScreenId = ""
// const setShareScreenId = (id: string) => shareScreenId = id
Expand Down
1 change: 1 addition & 0 deletions webapp/lib/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ async function delStream(roomId: string, streamId: string): Promise<any> {
'Authorization': `Bearer ${token}`,
},
method: 'DELETE',
keepalive: true,
})
}

Expand Down

0 comments on commit 409ad2a

Please sign in to comment.