From c33dd8f856c0ea716aa4e02ba0148db994e29e5a Mon Sep 17 00:00:00 2001 From: the-djmaze <> Date: Tue, 6 Aug 2024 21:41:52 +0200 Subject: [PATCH] Centralize tryToClose() for all popups --- dev/Knoin/AbstractViews.js | 5 ++--- dev/Knoin/Knoin.js | 2 +- dev/View/Popup/Compose.js | 8 ++++---- dev/View/Popup/Contacts.js | 4 ---- .../v/0.0.0/app/templates/Views/User/PopupsIdentity.html | 2 +- 5 files changed, 8 insertions(+), 13 deletions(-) diff --git a/dev/Knoin/AbstractViews.js b/dev/Knoin/AbstractViews.js index 828318b300..409e44386e 100644 --- a/dev/Knoin/AbstractViews.js +++ b/dev/Knoin/AbstractViews.js @@ -60,10 +60,9 @@ export class AbstractViewPopup extends AbstractView this.keyScope.scope = name; this.modalVisible = ko.observable(false).extend({ rateLimit: 0 }); this.close = () => this.modalVisible(false); + this.tryToClose = () => (false === this.onClose()) || this.close(); addShortcut('escape,close', '', name, () => { - if (this.modalVisible() && false !== this.onClose()) { - this.close(); - } + this.modalVisible() && this.tryToClose(); return false; // return true; Issue with supported modal close }); diff --git a/dev/Knoin/Knoin.js b/dev/Knoin/Knoin.js index df348375c8..12d07d1cbe 100644 --- a/dev/Knoin/Knoin.js +++ b/dev/Knoin/Knoin.js @@ -167,7 +167,7 @@ const if (screenName && fireEvent('sm-show-screen', screenName + (subPart ? '/' + subPart : ''), 1)) { // Close all popups for (let vm of visiblePopups) { - (false === vm.onClose()) || vm.close(); + vm.tryToClose(); } let vmScreen = screen(screenName); diff --git a/dev/View/Popup/Compose.js b/dev/View/Popup/Compose.js index 9c4e639545..3a875d5879 100644 --- a/dev/View/Popup/Compose.js +++ b/dev/View/Popup/Compose.js @@ -298,7 +298,7 @@ export class ComposePopupView extends AbstractViewPopup { ] }); - this.tryToClose = this.tryToClose.debounce(200); + this.doClose = this.doClose.debounce(200); this.iTimer = 0; @@ -665,7 +665,7 @@ export class ComposePopupView extends AbstractViewPopup { this.saveCommand(); } - this.tryToClose(); + this.doClose(); } contactsCommand() { @@ -1072,7 +1072,7 @@ export class ComposePopupView extends AbstractViewPopup { }, 100); } - tryToClose() { + doClose() { if (AskPopupView.hidden()) { if (ComposePopupView.inEdit() || (this.isEmptyForm() && !this.draftUid())) { this.close(); @@ -1218,7 +1218,7 @@ export class ComposePopupView extends AbstractViewPopup { }); addShortcut('escape,close', 'shift', ScopeCompose, () => { - this.tryToClose(); + this.doClose(); return false; }); diff --git a/dev/View/Popup/Contacts.js b/dev/View/Popup/Contacts.js index 15b6d61f30..342a6d5049 100644 --- a/dev/View/Popup/Contacts.js +++ b/dev/View/Popup/Contacts.js @@ -314,10 +314,6 @@ export class ContactsPopupView extends AbstractViewPopup { } } - tryToClose() { - (false === this.onClose()) || this.close(); - } - onClose() { const contact = this.contact(); if (AskPopupView.hidden() && contact?.hasChanges()) { diff --git a/snappymail/v/0.0.0/app/templates/Views/User/PopupsIdentity.html b/snappymail/v/0.0.0/app/templates/Views/User/PopupsIdentity.html index ebf739b656..201205a663 100644 --- a/snappymail/v/0.0.0/app/templates/Views/User/PopupsIdentity.html +++ b/snappymail/v/0.0.0/app/templates/Views/User/PopupsIdentity.html @@ -1,5 +1,5 @@
- × + ×