Skip to content

Commit eea593e

Browse files
committed
fix multiple on close handler
1 parent c95d6f3 commit eea593e

File tree

1 file changed

+6
-11
lines changed

1 file changed

+6
-11
lines changed

src/index.js

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ if (isWindows) {
2626
}
2727

2828
// Force single window
29-
// if (process.platform !== 'darwin') {
3029
const isSecondInstance = app.makeSingleInstance(() => {
3130
console.log(mainWindow);
3231
console.log('isMinimized', mainWindow.isMinimized);
@@ -40,7 +39,6 @@ if (isSecondInstance) {
4039
app.exit();
4140
}
4241

43-
// }
4442

4543
// Initialize Settings
4644
const settings = new Settings();
@@ -89,9 +87,13 @@ const createWindow = async () => {
8987
// when you should delete the corresponding element.
9088
if (!willQuitApp && (settings.get('runInBackground') === undefined || settings.get('runInBackground'))) {
9189
e.preventDefault();
92-
mainWindow.hide();
90+
if (isWindows) {
91+
mainWindow.minimize();
92+
} else {
93+
mainWindow.hide();
94+
}
9395

94-
if (process.platform === 'win32') {
96+
if (isWindows && settings.get('minimizeToSystemTray')) {
9597
mainWindow.setSkipTaskbar(true);
9698
}
9799
} else {
@@ -114,13 +116,6 @@ const createWindow = async () => {
114116
app.isMaximized = true;
115117
});
116118

117-
mainWindow.on('close', (e) => {
118-
if (settings.get('minimizeToSystemTray') && settings.get('runInBackground')) {
119-
e.preventDefault();
120-
mainWindow.minimize();
121-
}
122-
});
123-
124119
mainWindow.on('unmaximize', () => {
125120
app.isMaximized = false;
126121
});

0 commit comments

Comments
 (0)