From b1e08639bebae31873e1916a785d79d29cf5dbd6 Mon Sep 17 00:00:00 2001 From: Vijay Aravamudhan Date: Mon, 13 Sep 2021 11:26:19 +0530 Subject: Better implementation of confirmation while quitting Ferdi (#1919) Remove duplication and reuse method to return typesafe boolean from settings. Better fix for #1879 --- src/lib/Menu.js | 28 ++++++---------------------- 1 file changed, 6 insertions(+), 22 deletions(-) (limited to 'src/lib/Menu.js') 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 { const tpl = _titleBarTemplateFactory(intl, this.stores.settings.app.locked); const { actions } = this; - // TODO: Extract this into a reusable component and remove the duplications - const quitApp = () => { - const yesButtonIndex = 0; - let selection = yesButtonIndex; - if (window.ferdi.stores.settings.app.confirmOnQuit) { - selection = dialog.showMessageBoxSync(app.mainWindow, { - type: 'question', - message: intl.formatMessage(globalMessages.quit), - detail: intl.formatMessage(globalMessages.quitConfirmation), - buttons: [ - intl.formatMessage(globalMessages.yes), - intl.formatMessage(globalMessages.no), - ], - }); - } - if (selection === yesButtonIndex) { - app.quit(); - } - }; - if (!isMac) { tpl[1].submenu.push({ label: intl.formatMessage(menuItems.autohideMenuBar), @@ -816,7 +796,9 @@ export default class FranzMenu { { label: intl.formatMessage(globalMessages.quit), accelerator: `${cmdOrCtrlShortcutKey()}+Q`, - click: quitApp, + click() { + app.quit(); + }, }, ], }); @@ -874,7 +856,9 @@ export default class FranzMenu { { label: intl.formatMessage(globalMessages.quit), accelerator: `${cmdOrCtrlShortcutKey()}+Q`, - click: quitApp, + click() { + app.quit(); + }, }, ]; -- cgit v1.2.3-54-g00ecf