aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG.md6
-rw-r--r--src/environment.js1
-rw-r--r--src/index.js53
-rw-r--r--src/lib/Menu.js28
-rw-r--r--src/lib/Tray.js1
5 files changed, 48 insertions, 41 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 71089e820..7c36c5141 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,9 @@
1# [v5.6.2-nightly.3](https://github.com/getferdi/ferdi/compare/v5.6.2-nightly.2...v5.6.2-nightly.3) (2021-09-14)
2
3### Bug Fixes
4
5- Better implementation of prompting before quitting Ferdi (#1919) 💖 @vraravam
6
1# [v5.6.2-nightly.2](https://github.com/getferdi/ferdi/compare/v5.6.2-nightly.1...v5.6.2-nightly.2) (2021-09-13) 7# [v5.6.2-nightly.2](https://github.com/getferdi/ferdi/compare/v5.6.2-nightly.1...v5.6.2-nightly.2) (2021-09-13)
2 8
3### Services 9### Services
diff --git a/src/environment.js b/src/environment.js
index caeada94b..b30e3778d 100644
--- a/src/environment.js
+++ b/src/environment.js
@@ -171,6 +171,7 @@ export const DEFAULT_APP_SETTINGS = {
171 searchEngine: SEARCH_ENGINE_DDG, 171 searchEngine: SEARCH_ENGINE_DDG,
172 useVerticalStyle: false, 172 useVerticalStyle: false,
173 alwaysShowWorkspaces: false, 173 alwaysShowWorkspaces: false,
174 liftSingleInstanceLock: false,
174}; 175};
175 176
176export function aboutAppDetails() { 177export function aboutAppDetails() {
diff --git a/src/index.js b/src/index.js
index ae75865c6..7f1f77b4e 100644
--- a/src/index.js
+++ b/src/index.js
@@ -1,6 +1,6 @@
1/* eslint-disable import/first */ 1/* eslint-disable import/first */
2 2
3import { app, BrowserWindow, ipcMain, session } from 'electron'; 3import { app, BrowserWindow, ipcMain, session, dialog } from 'electron';
4 4
5import { emptyDirSync, ensureFileSync } from 'fs-extra'; 5import { emptyDirSync, ensureFileSync } from 'fs-extra';
6import { join } from 'path'; 6import { join } from 'path';
@@ -22,6 +22,7 @@ import {
22 userDataRecipesPath, 22 userDataRecipesPath,
23 userDataPath, 23 userDataPath,
24} from './environment'; 24} from './environment';
25import { ifUndefinedBoolean } from './jsUtils';
25 26
26import { mainIpcHandler as basicAuthHandler } from './features/basicAuth'; 27import { mainIpcHandler as basicAuthHandler } from './features/basicAuth';
27import ipcApi from './electron/ipc-api'; 28import ipcApi from './electron/ipc-api';
@@ -77,13 +78,14 @@ if (isWindows) {
77const settings = new Settings('app', DEFAULT_APP_SETTINGS); 78const settings = new Settings('app', DEFAULT_APP_SETTINGS);
78const proxySettings = new Settings('proxy'); 79const proxySettings = new Settings('proxy');
79 80
80if (settings.get('sentry')) { 81const retrieveSettingValue = (key, defaultValue = true) => ifUndefinedBoolean(settings.get(key), defaultValue);
82
83if (retrieveSettingValue('sentry')) {
81 // eslint-disable-next-line global-require 84 // eslint-disable-next-line global-require
82 require('./sentry'); 85 require('./sentry');
83} 86}
84 87
85// add `liftSingleInstanceLock` to settings.json to override the single instance lock 88const liftSingleInstanceLock = retrieveSettingValue('liftSingleInstanceLock', false);
86const liftSingleInstanceLock = settings.get('liftSingleInstanceLock') || false;
87 89
88// Force single window 90// Force single window
89const gotTheLock = liftSingleInstanceLock 91const gotTheLock = liftSingleInstanceLock
@@ -147,7 +149,7 @@ if (
147} 149}
148 150
149// Disable GPU acceleration 151// Disable GPU acceleration
150if (!settings.get('enableGPUAcceleration')) { 152if (!retrieveSettingValue('enableGPUAcceleration', false)) {
151 debug('Disable GPU Acceleration'); 153 debug('Disable GPU Acceleration');
152 app.disableHardwareAcceleration(); 154 app.disableHardwareAcceleration();
153} 155}
@@ -176,7 +178,7 @@ const createWindow = () => {
176 } 178 }
177 179
178 // Create the browser window. 180 // Create the browser window.
179 const backgroundColor = settings.get('darkMode') 181 const backgroundColor = retrieveSettingValue('darkMode', false)
180 ? '#1E1E1E' 182 ? '#1E1E1E'
181 : settings.get('accentColor'); 183 : settings.get('accentColor');
182 184
@@ -190,7 +192,7 @@ const createWindow = () => {
190 show: false, 192 show: false,
191 titleBarStyle: isMac ? 'hidden' : '', 193 titleBarStyle: isMac ? 'hidden' : '',
192 frame: isLinux, 194 frame: isLinux,
193 spellcheck: settings.get('enableSpellchecking'), 195 spellcheck: retrieveSettingValue('enableSpellchecking'),
194 backgroundColor, 196 backgroundColor,
195 webPreferences: { 197 webPreferences: {
196 nodeIntegration: true, 198 nodeIntegration: true,
@@ -268,15 +270,14 @@ const createWindow = () => {
268 // when you should delete the corresponding element. 270 // when you should delete the corresponding element.
269 if ( 271 if (
270 !willQuitApp && 272 !willQuitApp &&
271 (settings.get('runInBackground') === undefined || 273 retrieveSettingValue('runInBackground')
272 settings.get('runInBackground'))
273 ) { 274 ) {
274 e.preventDefault(); 275 e.preventDefault();
275 if (isWindows) { 276 if (isWindows) {
276 debug('Window: minimize'); 277 debug('Window: minimize');
277 mainWindow.minimize(); 278 mainWindow.minimize();
278 279
279 if (settings.get('closeToSystemTray')) { 280 if (retrieveSettingValue('closeToSystemTray')) {
280 debug('Skip taskbar: true'); 281 debug('Skip taskbar: true');
281 mainWindow.setSkipTaskbar(true); 282 mainWindow.setSkipTaskbar(true);
282 } 283 }
@@ -300,7 +301,7 @@ const createWindow = () => {
300 mainWindow.on('minimize', () => { 301 mainWindow.on('minimize', () => {
301 app.wasMaximized = app.isMaximized; 302 app.wasMaximized = app.isMaximized;
302 303
303 if (settings.get('minimizeToSystemTray')) { 304 if (retrieveSettingValue('minimizeToSystemTray')) {
304 debug('Skip taskbar: true'); 305 debug('Skip taskbar: true');
305 mainWindow.setSkipTaskbar(true); 306 mainWindow.setSkipTaskbar(true);
306 trayIcon.show(); 307 trayIcon.show();
@@ -326,7 +327,7 @@ const createWindow = () => {
326 mainWindow.maximize(); 327 mainWindow.maximize();
327 } 328 }
328 329
329 if (!settings.get('enableSystemTray')) { 330 if (!retrieveSettingValue('enableSystemTray')) {
330 debug('Tray: hiding tray icon'); 331 debug('Tray: hiding tray icon');
331 trayIcon.hide(); 332 trayIcon.hide();
332 } 333 }
@@ -351,7 +352,7 @@ const createWindow = () => {
351 openExternalUrl(url); 352 openExternalUrl(url);
352 }); 353 });
353 354
354 if (settings.get('startMinimized')) { 355 if (retrieveSettingValue('startMinimized', false)) {
355 mainWindow.hide(); 356 mainWindow.hide();
356 } else { 357 } else {
357 mainWindow.show(); 358 mainWindow.show();
@@ -551,10 +552,7 @@ ipcMain.on('stop-find-in-page', (e, action) => {
551app.on('window-all-closed', () => { 552app.on('window-all-closed', () => {
552 // On OS X it is common for applications and their menu bar 553 // On OS X it is common for applications and their menu bar
553 // to stay active until the user quits explicitly with Cmd + Q 554 // to stay active until the user quits explicitly with Cmd + Q
554 if ( 555 if (retrieveSettingValue('runInBackground')) {
555 settings.get('runInBackground') === undefined ||
556 settings.get('runInBackground')
557 ) {
558 debug('Window: all windows closed, quit app'); 556 debug('Window: all windows closed, quit app');
559 app.quit(); 557 app.quit();
560 } else { 558 } else {
@@ -562,8 +560,25 @@ app.on('window-all-closed', () => {
562 } 560 }
563}); 561});
564 562
565app.on('before-quit', () => { 563app.on('before-quit', (event) => {
566 willQuitApp = true; 564 const yesButtonIndex = 0;
565 let selection = yesButtonIndex;
566 if (retrieveSettingValue('confirmOnQuit')) {
567 selection = dialog.showMessageBoxSync(app.mainWindow, {
568 type: 'question',
569 message: 'Quit',
570 detail: 'Do you really want to quit Ferdi?',
571 buttons: [
572 'Yes',
573 'No',
574 ],
575 });
576 }
577 if (selection === yesButtonIndex) {
578 willQuitApp = true;
579 } else {
580 event.preventDefault();
581 }
567}); 582});
568 583
569app.on('activate', () => { 584app.on('activate', () => {
diff --git a/src/lib/Menu.js b/src/lib/Menu.js
index 324838441..5aa575df7 100644
--- a/src/lib/Menu.js
+++ b/src/lib/Menu.js
@@ -592,26 +592,6 @@ export default class FranzMenu {
592 const tpl = _titleBarTemplateFactory(intl, this.stores.settings.app.locked); 592 const tpl = _titleBarTemplateFactory(intl, this.stores.settings.app.locked);
593 const { actions } = this; 593 const { actions } = this;
594 594
595 // TODO: Extract this into a reusable component and remove the duplications
596 const quitApp = () => {
597 const yesButtonIndex = 0;
598 let selection = yesButtonIndex;
599 if (window.ferdi.stores.settings.app.confirmOnQuit) {
600 selection = dialog.showMessageBoxSync(app.mainWindow, {
601 type: 'question',
602 message: intl.formatMessage(globalMessages.quit),
603 detail: intl.formatMessage(globalMessages.quitConfirmation),
604 buttons: [
605 intl.formatMessage(globalMessages.yes),
606 intl.formatMessage(globalMessages.no),
607 ],
608 });
609 }
610 if (selection === yesButtonIndex) {
611 app.quit();
612 }
613 };
614
615 if (!isMac) { 595 if (!isMac) {
616 tpl[1].submenu.push({ 596 tpl[1].submenu.push({
617 label: intl.formatMessage(menuItems.autohideMenuBar), 597 label: intl.formatMessage(menuItems.autohideMenuBar),
@@ -816,7 +796,9 @@ export default class FranzMenu {
816 { 796 {
817 label: intl.formatMessage(globalMessages.quit), 797 label: intl.formatMessage(globalMessages.quit),
818 accelerator: `${cmdOrCtrlShortcutKey()}+Q`, 798 accelerator: `${cmdOrCtrlShortcutKey()}+Q`,
819 click: quitApp, 799 click() {
800 app.quit();
801 },
820 }, 802 },
821 ], 803 ],
822 }); 804 });
@@ -874,7 +856,9 @@ export default class FranzMenu {
874 { 856 {
875 label: intl.formatMessage(globalMessages.quit), 857 label: intl.formatMessage(globalMessages.quit),
876 accelerator: `${cmdOrCtrlShortcutKey()}+Q`, 858 accelerator: `${cmdOrCtrlShortcutKey()}+Q`,
877 click: quitApp, 859 click() {
860 app.quit();
861 },
878 }, 862 },
879 ]; 863 ];
880 864
diff --git a/src/lib/Tray.js b/src/lib/Tray.js
index f5970f7e7..7360611cd 100644
--- a/src/lib/Tray.js
+++ b/src/lib/Tray.js
@@ -10,6 +10,7 @@ const INDICATOR_TRAY_PLAIN = 'tray';
10const INDICATOR_TRAY_UNREAD = 'tray-unread'; 10const INDICATOR_TRAY_UNREAD = 'tray-unread';
11const INDICATOR_TRAY_INDIRECT = 'tray-indirect'; 11const INDICATOR_TRAY_INDIRECT = 'tray-indirect';
12 12
13// TODO: Need to support i18n for a lot of the hard-coded strings in this file
13export default class TrayIcon { 14export default class TrayIcon {
14 trayIcon = null; 15 trayIcon = null;
15 16