Skip to content

Commit

Permalink
fix multiple on close handler
Browse files Browse the repository at this point in the history
  • Loading branch information
adlk committed Nov 6, 2017
1 parent c95d6f3 commit eea593e
Showing 1 changed file with 6 additions and 11 deletions.
17 changes: 6 additions & 11 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ if (isWindows) {
}

// Force single window
// if (process.platform !== 'darwin') {
const isSecondInstance = app.makeSingleInstance(() => {
console.log(mainWindow);
console.log('isMinimized', mainWindow.isMinimized);
Expand All @@ -40,7 +39,6 @@ if (isSecondInstance) {
app.exit();
}

// }

// Initialize Settings
const settings = new Settings();
Expand Down Expand Up @@ -89,9 +87,13 @@ const createWindow = async () => {
// when you should delete the corresponding element.
if (!willQuitApp && (settings.get('runInBackground') === undefined || settings.get('runInBackground'))) {
e.preventDefault();
mainWindow.hide();
if (isWindows) {
mainWindow.minimize();
} else {
mainWindow.hide();
}

if (process.platform === 'win32') {
if (isWindows && settings.get('minimizeToSystemTray')) {
mainWindow.setSkipTaskbar(true);
}
} else {
Expand All @@ -114,13 +116,6 @@ const createWindow = async () => {
app.isMaximized = true;
});

mainWindow.on('close', (e) => {
if (settings.get('minimizeToSystemTray') && settings.get('runInBackground')) {
e.preventDefault();
mainWindow.minimize();
}
});

mainWindow.on('unmaximize', () => {
app.isMaximized = false;
});
Expand Down

0 comments on commit eea593e

Please sign in to comment.