Remove 'focus' event listener when leaving from index.html

This commit is contained in:
Yuya Ochiai
2016-01-14 21:51:06 +09:00
parent 0cff18b210
commit d6afda37f2

View File

@@ -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) {