diff options
Diffstat (limited to 'src/index.js')
-rw-r--r-- | src/index.js | 30 |
1 files changed, 16 insertions, 14 deletions
diff --git a/src/index.js b/src/index.js index 9f384f5fa..933637688 100644 --- a/src/index.js +++ b/src/index.js | |||
@@ -76,10 +76,10 @@ if (isWindows) { | |||
76 | const settings = new Settings('app', DEFAULT_APP_SETTINGS); | 76 | const settings = new Settings('app', DEFAULT_APP_SETTINGS); |
77 | const proxySettings = new Settings('proxy'); | 77 | const proxySettings = new Settings('proxy'); |
78 | 78 | ||
79 | const retrieveSettingValue = (key, defaultValue = true) => | 79 | const retrieveSettingValue = (key, defaultValue) => |
80 | ifUndefinedBoolean(settings.get(key), defaultValue); | 80 | ifUndefinedBoolean(settings.get(key), defaultValue); |
81 | 81 | ||
82 | if (retrieveSettingValue('sentry')) { | 82 | if (retrieveSettingValue('sentry', DEFAULT_APP_SETTINGS.sentry)) { |
83 | // eslint-disable-next-line global-require | 83 | // eslint-disable-next-line global-require |
84 | require('./sentry'); | 84 | require('./sentry'); |
85 | } | 85 | } |
@@ -196,7 +196,7 @@ const createWindow = () => { | |||
196 | frame: isLinux, | 196 | frame: isLinux, |
197 | backgroundColor, | 197 | backgroundColor, |
198 | webPreferences: { | 198 | webPreferences: { |
199 | spellcheck: retrieveSettingValue('enableSpellchecking'), | 199 | spellcheck: retrieveSettingValue('enableSpellchecking', DEFAULT_APP_SETTINGS.enableSpellchecking), |
200 | nodeIntegration: true, | 200 | nodeIntegration: true, |
201 | contextIsolation: false, | 201 | contextIsolation: false, |
202 | webviewTag: true, | 202 | webviewTag: true, |
@@ -270,13 +270,13 @@ const createWindow = () => { | |||
270 | // Dereference the window object, usually you would store windows | 270 | // Dereference the window object, usually you would store windows |
271 | // in an array if your app supports multi windows, this is the time | 271 | // in an array if your app supports multi windows, this is the time |
272 | // when you should delete the corresponding element. | 272 | // when you should delete the corresponding element. |
273 | if (!willQuitApp && retrieveSettingValue('runInBackground')) { | 273 | if (!willQuitApp && retrieveSettingValue('runInBackground', DEFAULT_APP_SETTINGS.runInBackground)) { |
274 | e.preventDefault(); | 274 | e.preventDefault(); |
275 | if (isWindows) { | 275 | if (isWindows) { |
276 | debug('Window: minimize'); | 276 | debug('Window: minimize'); |
277 | mainWindow.minimize(); | 277 | mainWindow.minimize(); |
278 | 278 | ||
279 | if (retrieveSettingValue('closeToSystemTray')) { | 279 | if (retrieveSettingValue('closeToSystemTray', DEFAULT_APP_SETTINGS.closeToSystemTray)) { |
280 | debug('Skip taskbar: true'); | 280 | debug('Skip taskbar: true'); |
281 | mainWindow.setSkipTaskbar(true); | 281 | mainWindow.setSkipTaskbar(true); |
282 | } | 282 | } |
@@ -300,7 +300,7 @@ const createWindow = () => { | |||
300 | mainWindow.on('minimize', () => { | 300 | mainWindow.on('minimize', () => { |
301 | app.wasMaximized = app.isMaximized; | 301 | app.wasMaximized = app.isMaximized; |
302 | 302 | ||
303 | if (retrieveSettingValue('minimizeToSystemTray')) { | 303 | if (retrieveSettingValue('minimizeToSystemTray', DEFAULT_APP_SETTINGS.minimizeToSystemTray)) { |
304 | debug('Skip taskbar: true'); | 304 | debug('Skip taskbar: true'); |
305 | mainWindow.setSkipTaskbar(true); | 305 | mainWindow.setSkipTaskbar(true); |
306 | trayIcon.show(); | 306 | trayIcon.show(); |
@@ -326,7 +326,7 @@ const createWindow = () => { | |||
326 | mainWindow.maximize(); | 326 | mainWindow.maximize(); |
327 | } | 327 | } |
328 | 328 | ||
329 | if (!retrieveSettingValue('enableSystemTray')) { | 329 | if (!retrieveSettingValue('enableSystemTray', DEFAULT_APP_SETTINGS.enableSystemTray)) { |
330 | debug('Tray: hiding tray icon'); | 330 | debug('Tray: hiding tray icon'); |
331 | trayIcon.hide(); | 331 | trayIcon.hide(); |
332 | } | 332 | } |
@@ -351,17 +351,19 @@ const createWindow = () => { | |||
351 | openExternalUrl(url); | 351 | openExternalUrl(url); |
352 | }); | 352 | }); |
353 | 353 | ||
354 | if (retrieveSettingValue('startMinimized', false)) { | 354 | if (retrieveSettingValue('startMinimized', DEFAULT_APP_SETTINGS.startMinimized)) { |
355 | mainWindow.hide(); | 355 | mainWindow.hide(); |
356 | } else { | 356 | } else { |
357 | mainWindow.show(); | 357 | mainWindow.show(); |
358 | } | 358 | } |
359 | 359 | ||
360 | app.whenReady().then(() => { | 360 | app.whenReady().then(() => { |
361 | // Toggle the window on 'Alt+X' | 361 | if (retrieveSettingValue('enableGlobalHideShortcut', DEFAULT_APP_SETTINGS.enableGlobalHideShortcut)) { |
362 | globalShortcut.register(`${altKey()}+X`, () => { | 362 | // Toggle the window on 'Alt+X' |
363 | trayIcon.trayMenuTemplate[0].click(); | 363 | globalShortcut.register(`${altKey()}+X`, () => { |
364 | }); | 364 | trayIcon.trayMenuTemplate[0].click(); |
365 | }); | ||
366 | } | ||
365 | }); | 367 | }); |
366 | }; | 368 | }; |
367 | 369 | ||
@@ -578,7 +580,7 @@ ipcMain.on('set-spellchecker-locales', (e, { locale, serviceId }) => { | |||
578 | app.on('window-all-closed', () => { | 580 | app.on('window-all-closed', () => { |
579 | // On OS X it is common for applications and their menu bar | 581 | // On OS X it is common for applications and their menu bar |
580 | // to stay active until the user quits explicitly with Cmd + Q | 582 | // to stay active until the user quits explicitly with Cmd + Q |
581 | if (retrieveSettingValue('runInBackground')) { | 583 | if (retrieveSettingValue('runInBackground', DEFAULT_APP_SETTINGS.runInBackground)) { |
582 | debug('Window: all windows closed, quit app'); | 584 | debug('Window: all windows closed, quit app'); |
583 | app.quit(); | 585 | app.quit(); |
584 | } else { | 586 | } else { |
@@ -589,7 +591,7 @@ app.on('window-all-closed', () => { | |||
589 | app.on('before-quit', event => { | 591 | app.on('before-quit', event => { |
590 | const yesButtonIndex = 0; | 592 | const yesButtonIndex = 0; |
591 | let selection = yesButtonIndex; | 593 | let selection = yesButtonIndex; |
592 | if (retrieveSettingValue('confirmOnQuit')) { | 594 | if (retrieveSettingValue('confirmOnQuit', DEFAULT_APP_SETTINGS.confirmOnQuit)) { |
593 | selection = dialog.showMessageBoxSync(app.mainWindow, { | 595 | selection = dialog.showMessageBoxSync(app.mainWindow, { |
594 | type: 'question', | 596 | type: 'question', |
595 | message: 'Quit', | 597 | message: 'Quit', |