From 3d18ff16d18c5a18441e230a0f9ef56875a79059 Mon Sep 17 00:00:00 2001 From: Germain Souquet Date: Thu, 25 Mar 2021 14:50:33 +0000 Subject: [PATCH] Attempt to minimise the window first rather than exiting --- src/electron-main.js | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/electron-main.js b/src/electron-main.js index 90ef3e0..bf5ecf5 100644 --- a/src/electron-main.js +++ b/src/electron-main.js @@ -927,6 +927,16 @@ app.on('ready', async () => { mainWindow = global.mainWindow = null; }); mainWindow.on('close', async (e) => { + // If we are not quitting and have a tray icon then minimize to tray + if (!global.appQuitting && (tray.hasTray() || process.platform === 'darwin')) { + // On Mac, closing the window just hides it + // (this is generally how single-window Mac apps + // behave, eg. Mail.app) + e.preventDefault(); + mainWindow.hide(); + return false; + } + if (store.get('warnBeforeExit', true)) { const shouldCancelCloseRequest = dialog.showMessageBoxSync(mainWindow, { type: "question", @@ -941,16 +951,6 @@ app.on('ready', async () => { return false; } } - - // If we are not quitting and have a tray icon then minimize to tray - if (!global.appQuitting && (tray.hasTray() || process.platform === 'darwin')) { - // On Mac, closing the window just hides it - // (this is generally how single-window Mac apps - // behave, eg. Mail.app) - e.preventDefault(); - mainWindow.hide(); - return false; - } }); if (process.platform === 'win32') {