From 430687f4d6d301aaeaeeaa11ae34d971ac3280df Mon Sep 17 00:00:00 2001 From: TC Date: Sun, 26 Apr 2020 16:10:13 +0200 Subject: [PATCH] Hide the app (no quit) on close if tray enabled --- index.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/index.js b/index.js index d5cb15db..d146d90a 100644 --- a/index.js +++ b/index.js @@ -10,6 +10,7 @@ const { autoUpdate, getEnabledPlugins, isAppVisible, + isTrayEnabled, store, } = require("./store"); const { fileExists, injectCSS } = require("./plugins/utils"); @@ -187,12 +188,16 @@ app.on("ready", () => { if (!isAppVisible()) { app.dock.hide(); } + } - var forceQuit = false; - app.on("before-quit", () => { - forceQuit = true; - }); + var forceQuit = false; + app.on("before-quit", () => { + forceQuit = true; + }); + + if (is.macOS() || isTrayEnabled()) { mainWindow.on("close", (event) => { + // Hide the window instead of quitting (quit is available in tray options) if (!forceQuit) { event.preventDefault(); mainWindow.hide();