@@ -86,8 +86,6 @@ const store = new Store({ name: "electron-config" });
8686
8787let mainWindow = null ;
8888global . appQuitting = false ;
89- global . showTrayIcon = store . get ( "showTrayIcon" , true ) ;
90- global . minimizeToTray = global . showTrayIcon && store . get ( 'minimizeToTray' , true ) ;
9189
9290// It's important to call `path.join` so we don't end up with the packaged asar in the final path.
9391const iconFile = `riot.${ process . platform === 'win32' ? 'ico' : 'png' } ` ;
@@ -174,25 +172,17 @@ ipcMain.on('ipcCall', async function(ev, payload) {
174172 launcher . disable ( ) ;
175173 }
176174 break ;
177- case 'getTrayIconEnabled ' :
178- ret = global . showTrayIcon ;
175+ case 'getMinimizeToTrayEnabled ' :
176+ ret = tray . hasTray ( ) ;
179177 break ;
180- case 'setTrayIconEnabled ' :
178+ case 'setMinimizeToTrayEnabled ' :
181179 if ( args [ 0 ] ) {
182180 // Create trayIcon icon
183181 tray . create ( trayConfig ) ;
184182 } else {
185183 tray . destroy ( ) ;
186184 }
187- store . set ( 'minimizeToTray' , global . showTrayIcon = args [ 0 ] ) ;
188- // re-evaluate whether we should be minimizing to tray
189- global . minimizeToTray = global . showTrayIcon && store . get ( 'minimizeToTray' , true ) ;
190- break ;
191- case 'getMinimizeToTrayEnabled' :
192- ret = global . minimizeToTray ;
193- break ;
194- case 'setMinimizeToTrayEnabled' :
195- store . set ( 'minimizeToTray' , global . minimizeToTray = args [ 0 ] ) ;
185+ store . set ( 'minimizeToTray' , args [ 0 ] ) ;
196186 break ;
197187 case 'getAutoHideMenuBarEnabled' :
198188 ret = global . mainWindow . isMenuBarAutoHide ( ) ;
@@ -388,7 +378,7 @@ app.on('ready', () => {
388378 mainWindow . hide ( ) ;
389379
390380 // Create trayIcon icon
391- if ( global . showTrayIcon ) tray . create ( trayConfig ) ;
381+ if ( store . get ( 'minimizeToTray' , true ) ) tray . create ( trayConfig ) ;
392382
393383 mainWindow . once ( 'ready-to-show' , ( ) => {
394384 mainWindowState . manage ( mainWindow ) ;
@@ -405,7 +395,8 @@ app.on('ready', () => {
405395 mainWindow = global . mainWindow = null ;
406396 } ) ;
407397 mainWindow . on ( 'close' , ( e ) => {
408- if ( global . minimizeToTray && ! global . appQuitting && ( tray . hasTray ( ) || process . platform === 'darwin' ) ) {
398+ // If we are not quitting and have a tray icon then minimize to tray
399+ if ( ! global . appQuitting && tray . hasTray ( ) ) {
409400 // On Mac, closing the window just hides it
410401 // (this is generally how single-window Mac apps
411402 // behave, eg. Mail.app)
0 commit comments