Permalink
Browse files

fix multiple on close handler

  • Loading branch information...
adlk committed Nov 6, 2017
1 parent c95d6f3 commit eea593eaab81ec311f86204d60623fe8f68b13ed
Showing with 6 additions and 11 deletions.
  1. +6 −11 src/index.js
@@ -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);
@@ -40,7 +39,6 @@ if (isSecondInstance) {
app.exit();
}
// }
// Initialize Settings
const settings = new Settings();
@@ -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 {
@@ -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;
});

0 comments on commit eea593e

Please sign in to comment.