From 9d92f93fcbf7208bc2ee37f3bf2fcb8e15629e07 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Wed, 3 May 2017 16:36:57 +0100 Subject: [PATCH] consolidate call onPageUnload handler into RoomView Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --- src/components/structures/RoomStatusBar.js | 12 ------------ src/components/structures/RoomView.js | 3 +++ 2 files changed, 3 insertions(+), 12 deletions(-) diff --git a/src/components/structures/RoomStatusBar.js b/src/components/structures/RoomStatusBar.js index 0cb246973b..0389b606aa 100644 --- a/src/components/structures/RoomStatusBar.js +++ b/src/components/structures/RoomStatusBar.js @@ -100,10 +100,6 @@ module.exports = React.createClass({ this._checkSize(); }, - componentDidMount: function() { - window.addEventListener('beforeunload', this.onPageUnload); - }, - componentDidUpdate: function() { this._checkSize(); }, @@ -115,7 +111,6 @@ module.exports = React.createClass({ client.removeListener("sync", this.onSyncStateChange); client.removeListener("RoomMember.typing", this.onRoomMemberTyping); } - window.removeEventListener('beforeunload', this.onPageUnload); }, onSyncStateChange: function(state, prevState) { @@ -133,13 +128,6 @@ module.exports = React.createClass({ }); }, - onPageUnload(event) { - if (this.props.hasActiveCall) { - return event.returnValue = - 'You seem to be in a call, are you sure you want to quit?'; - } - }, - // Check whether current size is greater than 0, if yes call props.onVisible _checkSize: function () { if (this.props.onVisible && this._getSize()) { diff --git a/src/components/structures/RoomView.js b/src/components/structures/RoomView.js index 9414a59e01..1b3ed6e80d 100644 --- a/src/components/structures/RoomView.js +++ b/src/components/structures/RoomView.js @@ -371,6 +371,9 @@ module.exports = React.createClass({ if (ContentMessages.getCurrentUploads().length > 0) { return event.returnValue = 'You seem to be uploading files, are you sure you want to quit?'; + } else if (this._getCallForRoom() && this.state.callState !== 'ended') { + return event.returnValue = + 'You seem to be in a call, are you sure you want to quit?'; } },