From 79d6b46841f3c3360ba1cb94dcef026cffb7b026 Mon Sep 17 00:00:00 2001 From: Robert Chen Date: Thu, 24 Sep 2020 15:34:45 +0800 Subject: [PATCH 1/2] Minimize window via command + w and close via command + q --- main.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/main.js b/main.js index 3714f8a9c85e1..55378e4640c5d 100644 --- a/main.js +++ b/main.js @@ -62,6 +62,20 @@ const mainWindow = (() => { return shell.openExternal(url); }); + // Flag to determine is user is trying to quit the whole application altogether + let quitting = false; + + // Closing the chat window should just hide it (vs. fully quitting the application) + browserWindow.on("close", (evt) => { + if (!quitting) { + evt.preventDefault(); + browserWindow.minimize(); + } + }); + + app.on('before-quit', () => quitting = true); + app.on('activate', () => browserWindow.show()); + ipcMain.on('request-visibility', (event) => { // This is how synchronous messages work in Electron // eslint-disable-next-line no-param-reassign From 2a59322cc1280bde95c260a319cf788e208c3e2d Mon Sep 17 00:00:00 2001 From: Robert Chen Date: Thu, 24 Sep 2020 15:39:23 +0800 Subject: [PATCH 2/2] Use single quote --- main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.js b/main.js index 55378e4640c5d..75d037eb33679 100644 --- a/main.js +++ b/main.js @@ -66,7 +66,7 @@ const mainWindow = (() => { let quitting = false; // Closing the chat window should just hide it (vs. fully quitting the application) - browserWindow.on("close", (evt) => { + browserWindow.on('close', (evt) => { if (!quitting) { evt.preventDefault(); browserWindow.minimize();