Skip to content
This repository has been archived by the owner on Aug 23, 2024. It is now read-only.

MacOS exit to tray #268

Merged
merged 3 commits into from
Mar 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/components/shared/setDefaultSettings.ts
Original file line number Diff line number Diff line change
@@ -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')) {
Expand Down Expand Up @@ -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')) {
Expand Down
8 changes: 8 additions & 0 deletions src/main.dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -538,6 +539,9 @@ const createWindow = async () => {
event.preventDefault();
mainWindow.hide();
}
if (forceQuit) {
app.exit();
}
});

if (isWindows()) {
Expand Down Expand Up @@ -586,6 +590,10 @@ const createWindow = async () => {
height: window.height,
});
});

app.on('before-quit', () => {
forceQuit = true;
});
}

mainWindow.once('maximize', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/menu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export default class MenuBuilder {
label: 'Quit',
accelerator: 'Command+Q',
click: () => {
app.quit();
app.exit();
},
},
],
Expand Down