aboutsummaryrefslogtreecommitdiffstats
path: root/src/index.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/index.js')
-rw-r--r--src/index.js29
1 files changed, 24 insertions, 5 deletions
diff --git a/src/index.js b/src/index.js
index 69cfa77e7..0e222c3d6 100644
--- a/src/index.js
+++ b/src/index.js
@@ -34,6 +34,7 @@ import {
34 DEFAULT_WINDOW_OPTIONS, 34 DEFAULT_WINDOW_OPTIONS,
35} from './config'; 35} from './config';
36import { asarPath } from './helpers/asar-helpers'; 36import { asarPath } from './helpers/asar-helpers';
37import { isValidExternalURL } from './helpers/url-helpers';
37/* eslint-enable import/first */ 38/* eslint-enable import/first */
38 39
39const debug = require('debug')('Franz:App'); 40const debug = require('debug')('Franz:App');
@@ -223,20 +224,24 @@ const createWindow = () => {
223 224
224 // Emitted when the window is closed. 225 // Emitted when the window is closed.
225 mainWindow.on('close', (e) => { 226 mainWindow.on('close', (e) => {
227 debug('Window: close window');
226 // Dereference the window object, usually you would store windows 228 // Dereference the window object, usually you would store windows
227 // in an array if your app supports multi windows, this is the time 229 // in an array if your app supports multi windows, this is the time
228 // when you should delete the corresponding element. 230 // when you should delete the corresponding element.
229 if (!willQuitApp && (settings.get('runInBackground') === undefined || settings.get('runInBackground'))) { 231 if (!willQuitApp && (settings.get('runInBackground') === undefined || settings.get('runInBackground'))) {
230 e.preventDefault(); 232 e.preventDefault();
231 if (isWindows) { 233 if (isWindows) {
234 debug('Window: minimize');
232 mainWindow.minimize(); 235 mainWindow.minimize();
236
237 if (settings.get('minimizeToSystemTray')) {
238 debug('Skip taskbar: true');
239 mainWindow.setSkipTaskbar(true);
240 }
233 } else { 241 } else {
242 debug('Window: hide');
234 mainWindow.hide(); 243 mainWindow.hide();
235 } 244 }
236
237 if (isWindows) {
238 mainWindow.setSkipTaskbar(true);
239 }
240 } else { 245 } else {
241 app.quit(); 246 app.quit();
242 } 247 }
@@ -248,32 +253,39 @@ const createWindow = () => {
248 app.wasMaximized = app.isMaximized; 253 app.wasMaximized = app.isMaximized;
249 254
250 if (settings.get('minimizeToSystemTray')) { 255 if (settings.get('minimizeToSystemTray')) {
256 debug('Skip taskbar: true');
251 mainWindow.setSkipTaskbar(true); 257 mainWindow.setSkipTaskbar(true);
252 trayIcon.show(); 258 trayIcon.show();
253 } 259 }
254 }); 260 });
255 261
256 mainWindow.on('maximize', () => { 262 mainWindow.on('maximize', () => {
263 debug('Window: maximize');
257 app.isMaximized = true; 264 app.isMaximized = true;
258 }); 265 });
259 266
260 mainWindow.on('unmaximize', () => { 267 mainWindow.on('unmaximize', () => {
268 debug('Window: unmaximize');
261 app.isMaximized = false; 269 app.isMaximized = false;
262 }); 270 });
263 271
264 mainWindow.on('restore', () => { 272 mainWindow.on('restore', () => {
273 debug('Window: restore');
265 mainWindow.setSkipTaskbar(false); 274 mainWindow.setSkipTaskbar(false);
266 275
267 if (app.wasMaximized) { 276 if (app.wasMaximized) {
277 debug('Window: was maximized before, maximize window');
268 mainWindow.maximize(); 278 mainWindow.maximize();
269 } 279 }
270 280
271 if (!settings.get('enableSystemTray')) { 281 if (!settings.get('enableSystemTray')) {
282 debug('Tray: hiding tray icon');
272 trayIcon.hide(); 283 trayIcon.hide();
273 } 284 }
274 }); 285 });
275 286
276 mainWindow.on('show', () => { 287 mainWindow.on('show', () => {
288 debug('Skip taskbar: false');
277 mainWindow.setSkipTaskbar(false); 289 mainWindow.setSkipTaskbar(false);
278 }); 290 });
279 291
@@ -281,8 +293,12 @@ const createWindow = () => {
281 app.isMaximized = mainWindow.isMaximized(); 293 app.isMaximized = mainWindow.isMaximized();
282 294
283 mainWindow.webContents.on('new-window', (e, url) => { 295 mainWindow.webContents.on('new-window', (e, url) => {
296 debug('Open url', url);
284 e.preventDefault(); 297 e.preventDefault();
285 shell.openExternal(url); 298
299 if (isValidExternalURL(url)) {
300 shell.openExternal(url);
301 }
286 }); 302 });
287}; 303};
288 304
@@ -360,7 +376,10 @@ app.on('window-all-closed', () => {
360 // to stay active until the user quits explicitly with Cmd + Q 376 // to stay active until the user quits explicitly with Cmd + Q
361 if (settings.get('runInBackground') === undefined 377 if (settings.get('runInBackground') === undefined
362 || settings.get('runInBackground')) { 378 || settings.get('runInBackground')) {
379 debug('Window: all windows closed, quit app');
363 app.quit(); 380 app.quit();
381 } else {
382 debug('Window: don\'t quit app');
364 } 383 }
365}); 384});
366 385