From 3c0c448502ab1cb134256a288dc571d936bff783 Mon Sep 17 00:00:00 2001 From: Martin Gondermann Date: Sun, 3 Jul 2016 22:13:48 +0200 Subject: [PATCH] Fix behaviour, if "Show icon on menu bar" was previously not selected --- src/browser/settings.jsx | 17 +++++++++++++++-- src/main.js | 5 +++++ 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/src/browser/settings.jsx b/src/browser/settings.jsx index ca28f35d..a22aa4f1 100644 --- a/src/browser/settings.jsx +++ b/src/browser/settings.jsx @@ -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(); + options.push(); } if (process.platform === 'win32') { diff --git a/src/main.js b/src/main.js index 7505751a..f37d6782 100644 --- a/src/main.js +++ b/src/main.js @@ -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.