From a2787994ae32bbefd0b5e0dc5ba38ddcd7056e49 Mon Sep 17 00:00:00 2001 From: Robin Townsend Date: Wed, 20 Apr 2022 12:14:08 -0400 Subject: [PATCH] Forcefully disconnect from video rooms on tab close --- src/stores/VideoChannelStore.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/stores/VideoChannelStore.ts b/src/stores/VideoChannelStore.ts index 0da2d06646e..14016800487 100644 --- a/src/stores/VideoChannelStore.ts +++ b/src/stores/VideoChannelStore.ts @@ -171,6 +171,7 @@ export default class VideoChannelStore extends AsyncStoreWithClient { this.connected = true; messaging.once(`action:${ElementWidgetActions.HangupCall}`, this.onHangup); + window.addEventListener("beforeunload", this.setDisconnected); this.emit(VideoChannelEvent.Connect, roomId); @@ -193,6 +194,7 @@ export default class VideoChannelStore extends AsyncStoreWithClient { public setDisconnected = async () => { this.activeChannel.off(`action:${ElementWidgetActions.HangupCall}`, this.onHangup); this.activeChannel.off(`action:${ElementWidgetActions.CallParticipants}`, this.onParticipants); + window.removeEventListener("beforeunload", this.setDisconnected); const roomId = this.roomId; this.activeChannel = null;