Centralize tryToClose() for all popups

This commit is contained in:
the-djmaze 2024-08-06 21:41:52 +02:00
parent fa15742edb
commit c33dd8f856
5 changed files with 8 additions and 13 deletions

View file

@ -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;
});

View file

@ -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()) {