aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Stefan Malzner <stefan@adlk.io>2017-11-06 14:47:05 +0100
committerLibravatar Stefan Malzner <stefan@adlk.io>2017-11-06 14:47:05 +0100
commiteea593eaab81ec311f86204d60623fe8f68b13ed (patch)
tree14fc65eba59ab6cc43156c89a75a5a58dcc64571
parentadd debugging output for mainWindow (diff)
downloadferdium-app-eea593eaab81ec311f86204d60623fe8f68b13ed.tar.gz
ferdium-app-eea593eaab81ec311f86204d60623fe8f68b13ed.tar.zst
ferdium-app-eea593eaab81ec311f86204d60623fe8f68b13ed.zip
fix multiple on close handler
-rw-r--r--src/index.js17
1 files changed, 6 insertions, 11 deletions
diff --git a/src/index.js b/src/index.js
index 4507913ad..3b86f09bc 100644
--- a/src/index.js
+++ b/src/index.js
@@ -26,7 +26,6 @@ if (isWindows) {
26} 26}
27 27
28// Force single window 28// Force single window
29// if (process.platform !== 'darwin') {
30const isSecondInstance = app.makeSingleInstance(() => { 29const isSecondInstance = app.makeSingleInstance(() => {
31 console.log(mainWindow); 30 console.log(mainWindow);
32 console.log('isMinimized', mainWindow.isMinimized); 31 console.log('isMinimized', mainWindow.isMinimized);
@@ -40,7 +39,6 @@ if (isSecondInstance) {
40 app.exit(); 39 app.exit();
41} 40}
42 41
43// }
44 42
45// Initialize Settings 43// Initialize Settings
46const settings = new Settings(); 44const settings = new Settings();
@@ -89,9 +87,13 @@ const createWindow = async () => {
89 // when you should delete the corresponding element. 87 // when you should delete the corresponding element.
90 if (!willQuitApp && (settings.get('runInBackground') === undefined || settings.get('runInBackground'))) { 88 if (!willQuitApp && (settings.get('runInBackground') === undefined || settings.get('runInBackground'))) {
91 e.preventDefault(); 89 e.preventDefault();
92 mainWindow.hide(); 90 if (isWindows) {
91 mainWindow.minimize();
92 } else {
93 mainWindow.hide();
94 }
93 95
94 if (process.platform === 'win32') { 96 if (isWindows && settings.get('minimizeToSystemTray')) {
95 mainWindow.setSkipTaskbar(true); 97 mainWindow.setSkipTaskbar(true);
96 } 98 }
97 } else { 99 } else {
@@ -114,13 +116,6 @@ const createWindow = async () => {
114 app.isMaximized = true; 116 app.isMaximized = true;
115 }); 117 });
116 118
117 mainWindow.on('close', (e) => {
118 if (settings.get('minimizeToSystemTray') && settings.get('runInBackground')) {
119 e.preventDefault();
120 mainWindow.minimize();
121 }
122 });
123
124 mainWindow.on('unmaximize', () => { 119 mainWindow.on('unmaximize', () => {
125 app.isMaximized = false; 120 app.isMaximized = false;
126 }); 121 });