Fix behaviour, if "Show icon on menu bar" was previously not selected

This commit is contained in:
Martin Gondermann
2016-07-03 22:13:48 +02:00
parent a1155bf989
commit 3c0c448502
2 changed files with 20 additions and 2 deletions

View File

@@ -47,6 +47,19 @@ var SettingsPage = React.createClass({
});
});
}
if (process.platform === 'darwin') {
var currentWindow = remote.getCurrentWindow();
if (currentWindow.tray) {
this.setState({
trayWasVisible: true
});
} else {
this.setState({
trayWasVisible: false
});
}
}
},
handleTeamsChange: function(teams) {
this.setState({
@@ -181,8 +194,8 @@ var SettingsPage = React.createClass({
}
if (process.platform === 'darwin') {
options.push(<Input key="inputMinimizeToTray" id="inputMinimizeToTray" ref="minimizeToTray" type="checkbox" label="Leave app running in notification area when the window is closed"
disabled={ !this.state.showTrayIcon } checked={ this.state.minimizeToTray } onChange={ this.handleChangeMinimizeToTray } />);
options.push(<Input key="inputMinimizeToTray" id="inputMinimizeToTray" ref="minimizeToTray" type="checkbox" label={ this.state.trayWasVisible || !this.state.showTrayIcon ? "Leave app running in notification area when the window is closed" : "Leave app running in notification area when the window is closed (available on next restart)" } disabled={ !this.state.showTrayIcon || !this.state.trayWasVisible } checked={ this.state.minimizeToTray }
onChange={ this.handleChangeMinimizeToTray } />);
}
if (process.platform === 'win32') {

View File

@@ -358,6 +358,11 @@ app.on('ready', function() {
if (shouldShowTrayIcon()) {
const tray_menu = require('./main/menus/tray').createDefault(mainWindow);
trayIcon.setContextMenu(tray_menu);
if (process.platform === 'darwin') {
// store a reference to the tray icon, for checking in the settings, if the application
// was restarted after setting "Show icon on menu bar"
mainWindow.tray = trayIcon;
}
}
// Open the DevTools.