diff options
author | 2021-09-13 11:26:19 +0530 | |
---|---|---|
committer | 2021-09-13 11:26:19 +0530 | |
commit | b1e08639bebae31873e1916a785d79d29cf5dbd6 (patch) | |
tree | a66066e463be2f8f1fcd026d22fdd99760cd0885 /src/lib | |
parent | 5.6.2-nightly.2 [skip ci] (diff) | |
download | ferdium-app-b1e08639bebae31873e1916a785d79d29cf5dbd6.tar.gz ferdium-app-b1e08639bebae31873e1916a785d79d29cf5dbd6.tar.zst ferdium-app-b1e08639bebae31873e1916a785d79d29cf5dbd6.zip |
Better implementation of confirmation while quitting Ferdi (#1919)
Remove duplication and reuse method to return typesafe boolean from settings.
Better fix for #1879
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/Menu.js | 28 | ||||
-rw-r--r-- | src/lib/Tray.js | 1 |
2 files changed, 7 insertions, 22 deletions
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'; | |||
10 | const INDICATOR_TRAY_UNREAD = 'tray-unread'; | 10 | const INDICATOR_TRAY_UNREAD = 'tray-unread'; |
11 | const INDICATOR_TRAY_INDIRECT = 'tray-indirect'; | 11 | const INDICATOR_TRAY_INDIRECT = 'tray-indirect'; |
12 | 12 | ||
13 | // TODO: Need to support i18n for a lot of the hard-coded strings in this file | ||
13 | export default class TrayIcon { | 14 | export default class TrayIcon { |
14 | trayIcon = null; | 15 | trayIcon = null; |
15 | 16 | ||