From fbbee5c4b13a36df1c3d89cdba739bc6d96e9cb7 Mon Sep 17 00:00:00 2001 From: Dani Palou Date: Thu, 20 Jul 2017 16:50:12 +0200 Subject: [PATCH] MOBILE-2180 desktop: Focus when relaunched and use exit instead of quit --- www/electron.js | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/www/electron.js b/www/electron.js index 9e149a52fac..7f7c6b03bdf 100644 --- a/www/electron.js +++ b/www/electron.js @@ -59,7 +59,7 @@ app.on('ready', function() { // Quit when all windows are closed. app.on('window-all-closed', () => { - app.quit(); + app.exit(); }); app.on('activate', () => { @@ -87,20 +87,24 @@ var shouldQuit = app.makeSingleInstance((argv, workingDirectory) => { // Another instance was launched. If it was launched with a URL, it should be in the second param. if (argv && argv[1]) { appLaunched(argv[1]); + } else { + focusApp(); } }); -if (shouldQuit) { +// For some reason, shouldQuit is always true in signed Mac apps so we should ingore it. +if (shouldQuit && os.platform().indexOf('darwin') == -1) { // It's not the main instance of the app, kill it. - app.quit(); -} else { - // Listen for open-url events (Mac OS only). - app.on('open-url', (event, url) => { - event.preventDefault(); - appLaunched(url); - }); + app.exit(); + return; } +// Listen for open-url events (Mac OS only). +app.on('open-url', (event, url) => { + event.preventDefault(); + appLaunched(url); +}); + function appLaunched(url) { // App was launched again with a URL. Focus the main window and send an event to treat the URL. if (mainWindow) {