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;