Windows/Linux: Fix broken Quit option in Tray icon

This also cleans up the code by handling quit in the same way for all
platforms, removing the special case in tray.js for darwin.

We already have a 'before-quit' handler in main/index.js, so this is
now handled there :)
This commit is contained in:
Feross Aboukhadijeh
2016-04-04 13:40:27 -07:00
parent 9d8e79fb35
commit ccaf0de63d
2 changed files with 18 additions and 18 deletions

View File

@@ -1,6 +1,7 @@
var electron = require('electron')
var app = electron.app
var ipcMain = electron.ipcMain
var autoUpdater = require('./auto-updater')
var config = require('../config')
@@ -62,8 +63,14 @@ function init () {
processArgv(argv)
})
app.on('before-quit', function () {
app.on('before-quit', function (e) {
if (app.isQuitting) return
app.isQuitting = true
e.preventDefault()
windows.main.send('dispatch', 'saveState') /* try to save state on exit */
ipcMain.once('savedState', () => app.quit())
setTimeout(() => app.quit(), 2000) /* quit after 2 secs, at most */
})
app.on('activate', function () {