Hide the app (no quit) on close if tray enabled

This commit is contained in:
TC
2020-04-26 16:10:13 +02:00
parent 45f4b3bc28
commit 430687f4d6

View File

@ -10,6 +10,7 @@ const {
autoUpdate, autoUpdate,
getEnabledPlugins, getEnabledPlugins,
isAppVisible, isAppVisible,
isTrayEnabled,
store, store,
} = require("./store"); } = require("./store");
const { fileExists, injectCSS } = require("./plugins/utils"); const { fileExists, injectCSS } = require("./plugins/utils");
@ -187,12 +188,16 @@ app.on("ready", () => {
if (!isAppVisible()) { if (!isAppVisible()) {
app.dock.hide(); app.dock.hide();
} }
}
var forceQuit = false; var forceQuit = false;
app.on("before-quit", () => { app.on("before-quit", () => {
forceQuit = true; forceQuit = true;
}); });
if (is.macOS() || isTrayEnabled()) {
mainWindow.on("close", (event) => { mainWindow.on("close", (event) => {
// Hide the window instead of quitting (quit is available in tray options)
if (!forceQuit) { if (!forceQuit) {
event.preventDefault(); event.preventDefault();
mainWindow.hide(); mainWindow.hide();