From d6afda37f2924383770e9985e5fc6daf4afddb59 Mon Sep 17 00:00:00 2001 From: Yuya Ochiai Date: Thu, 14 Jan 2016 21:51:06 +0900 Subject: [PATCH] Remove 'focus' event listener when leaving from index.html --- src/browser/index.jsx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/browser/index.jsx b/src/browser/index.jsx index 38be3d3f..190570d4 100644 --- a/src/browser/index.jsx +++ b/src/browser/index.jsx @@ -28,9 +28,15 @@ var MainPage = React.createClass({ }, componentDidMount: function() { var thisObj = this; - remote.getCurrentWindow().on('focus', function() { + var focusListener = function() { var webview = document.getElementById('mattermostView' + thisObj.state.key); webview.focus(); + }; + + var currentWindow = remote.getCurrentWindow(); + currentWindow.on('focus', focusListener); + window.addEventListener('beforeunload', function() { + currentWindow.removeListener('focus', focusListener); }); }, handleSelect: function(key) {