From 14fd298d293a7c7dac8afd727908b42b692e074e Mon Sep 17 00:00:00 2001 From: Luke Hines Date: Thu, 17 Mar 2022 21:38:35 +0000 Subject: [PATCH 1/3] respect MacOS menu quit --- src/main.dev.js | 8 ++++++++ src/menu.ts | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/main.dev.js b/src/main.dev.js index 6674deca..de008b48 100644 --- a/src/main.dev.js +++ b/src/main.dev.js @@ -49,6 +49,7 @@ replayActionMain(store); let mainWindow = null; let tray = null; let exitFromTray = false; +let forceQuit = false; if (process.env.NODE_ENV === 'production') { const sourceMapSupport = require('source-map-support'); @@ -538,6 +539,9 @@ const createWindow = async () => { event.preventDefault(); mainWindow.hide(); } + if (forceQuit) { + app.exit(); + } }); if (isWindows()) { @@ -586,6 +590,10 @@ const createWindow = async () => { height: window.height, }); }); + + app.on('before-quit', function() { + forceQuit = true; + }); } mainWindow.once('maximize', () => { diff --git a/src/menu.ts b/src/menu.ts index ffad5139..4383dc6a 100644 --- a/src/menu.ts +++ b/src/menu.ts @@ -68,7 +68,7 @@ export default class MenuBuilder { label: 'Quit', accelerator: 'Command+Q', click: () => { - app.quit(); + app.exit(); }, }, ], From 26526baa79eec50347e8cb974a5f3bd85a5700f1 Mon Sep 17 00:00:00 2001 From: Luke Hines Date: Thu, 17 Mar 2022 21:41:16 +0000 Subject: [PATCH 2/3] exit to tray default for MacOS --- src/components/shared/setDefaultSettings.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/components/shared/setDefaultSettings.ts b/src/components/shared/setDefaultSettings.ts index e9f43024..eb646017 100644 --- a/src/components/shared/setDefaultSettings.ts +++ b/src/components/shared/setDefaultSettings.ts @@ -1,6 +1,7 @@ import settings from 'electron-settings'; import path from 'path'; import i18n from '../../i18n/i18n'; +import { isMacOS } from '../../shared/utils'; const setDefaultSettings = (force: boolean) => { if (force || !settings.hasSync('discord.enabled')) { @@ -76,7 +77,11 @@ const setDefaultSettings = (force: boolean) => { } if (force || !settings.hasSync('exitToTray')) { - settings.setSync('exitToTray', false); + let defaultExitToTray = false; + if(isMacOS()) { + defaultExitToTray = true; + } + settings.setSync('exitToTray', defaultExitToTray); } if (force || !settings.hasSync('showDebugWindow')) { From 8e45eaac881878478bc04703dd96e93f879b52d4 Mon Sep 17 00:00:00 2001 From: Luke Hines Date: Thu, 17 Mar 2022 22:25:02 +0000 Subject: [PATCH 3/3] fix lint issues --- src/components/shared/setDefaultSettings.ts | 2 +- src/main.dev.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/shared/setDefaultSettings.ts b/src/components/shared/setDefaultSettings.ts index eb646017..e01aef7e 100644 --- a/src/components/shared/setDefaultSettings.ts +++ b/src/components/shared/setDefaultSettings.ts @@ -78,7 +78,7 @@ const setDefaultSettings = (force: boolean) => { if (force || !settings.hasSync('exitToTray')) { let defaultExitToTray = false; - if(isMacOS()) { + if (isMacOS()) { defaultExitToTray = true; } settings.setSync('exitToTray', defaultExitToTray); diff --git a/src/main.dev.js b/src/main.dev.js index de008b48..f0894b5d 100644 --- a/src/main.dev.js +++ b/src/main.dev.js @@ -591,7 +591,7 @@ const createWindow = async () => { }); }); - app.on('before-quit', function() { + app.on('before-quit', () => { forceQuit = true; }); }