Add context menu only once even if after reloading

Close #408
This commit is contained in:
Yuya Ochiai 2017-01-11 22:01:37 +09:00
parent 8d7bc31798
commit 97df4e1c42
2 changed files with 11 additions and 4 deletions

View file

@ -17,6 +17,7 @@ Release date: TBD
#### All Platforms
- Do not place the application window outside of the viewable area anymore, if the display it has been on has been removed
- Remove remaining badges after logging out of the team
- Fixed an issue where context menu appears many times after reloading
#### Windows
- Fixed an issue where an unexpected window appears while install/uninstalling

View file

@ -21,7 +21,8 @@ const MattermostView = React.createClass({
getInitialState() {
return {
errorInfo: null
errorInfo: null,
isContextMenuAdded: false
};
},
@ -78,6 +79,8 @@ const MattermostView = React.createClass({
}
});
// 'dom-ready' means "content has been loaded"
// So this would be emitted again when reloading a webview
webview.addEventListener('dom-ready', () => {
// webview.openDevTools();
@ -100,9 +103,12 @@ const MattermostView = React.createClass({
});
}
electronContextMenu({
window: webview
});
if (!this.state.isContextMenuAdded) {
electronContextMenu({
window: webview
});
this.setState({isContextMenuAdded: true});
}
});
webview.addEventListener('update-target-url', (event) => {