From 36feca6ce746bb6b46a21990cbedfbb8fec3337d Mon Sep 17 00:00:00 2001 From: the-djmaze <> Date: Sat, 26 Feb 2022 01:06:18 +0100 Subject: [PATCH] modalVisibility() to modalVisible() --- dev/Knoin/AbstractViews.js | 6 ++--- dev/Knoin/Knoin.js | 6 ++--- dev/View/Popup/Compose.js | 54 +++++++++++++++++--------------------- 3 files changed, 30 insertions(+), 36 deletions(-) diff --git a/dev/Knoin/AbstractViews.js b/dev/Knoin/AbstractViews.js index fdf39cb43..6c77911d3 100644 --- a/dev/Knoin/AbstractViews.js +++ b/dev/Knoin/AbstractViews.js @@ -58,9 +58,9 @@ export class AbstractViewPopup extends AbstractView { super('Popups' + name, ViewType.Popup); this.keyScope.scope = name; - this.modalVisibility = ko.observable(false).extend({ rateLimit: 0 }); + this.modalVisible = ko.observable(false).extend({ rateLimit: 0 }); shortcuts.add('escape,close', '', name, () => { - if (this.modalVisibility() && this.onClose()) { + if (this.modalVisible() && this.onClose()) { this.closeCommand(); return false; } @@ -90,7 +90,7 @@ AbstractViewPopup.showModal = function(params = []) { } AbstractViewPopup.hidden = function() { - return !this.__vm || !this.__vm.modalVisibility(); + return !this.__vm || !this.__vm.modalVisible(); } export class AbstractViewCenter extends AbstractView diff --git a/dev/Knoin/Knoin.js b/dev/Knoin/Knoin.js index 840aa3212..182373cfe 100644 --- a/dev/Knoin/Knoin.js +++ b/dev/Knoin/Knoin.js @@ -83,7 +83,7 @@ const } }; - vm.modalVisibility.subscribe(value => { + vm.modalVisible.subscribe(value => { if (value) { visiblePopups.add(vm); vmDom.style.zIndex = 3000 + (visiblePopups.size * 2); @@ -154,7 +154,7 @@ const */ hideScreenPopup = ViewModelClassToHide => { if (ViewModelClassToHide && ViewModelClassToHide.__vm && ViewModelClassToHide.__dom) { - ViewModelClassToHide.__vm.modalVisibility(false); + ViewModelClassToHide.__vm.modalVisible(false); } }, @@ -266,7 +266,7 @@ export const vm.onBeforeShow && vm.onBeforeShow(...params); - vm.modalVisibility(true); + vm.modalVisible(true); vm.onShow && vm.onShow(...params); } diff --git a/dev/View/Popup/Compose.js b/dev/View/Popup/Compose.js index 3dd3f5e54..5dde3ebec 100644 --- a/dev/View/Popup/Compose.js +++ b/dev/View/Popup/Compose.js @@ -534,19 +534,17 @@ export class ComposePopupView extends AbstractViewPopup { Remote.request('SendMessage', (iError, data) => { this.sending(false); - if (this.modalVisibility()) { - if (iError) { - if (Notification.CantSaveMessage === iError) { - this.sendSuccessButSaveError(true); - this.savedErrorDesc(i18n('COMPOSE/SAVED_ERROR_ON_SEND').trim()); - } else { - this.sendError(true); - this.sendErrorDesc(getNotification(iError, data && data.ErrorMessage) - || getNotification(Notification.CantSendMessage)); - } + if (iError) { + if (Notification.CantSaveMessage === iError) { + this.sendSuccessButSaveError(true); + this.savedErrorDesc(i18n('COMPOSE/SAVED_ERROR_ON_SEND').trim()); } else { - this.closeCommand(); + this.sendError(true); + this.sendErrorDesc(getNotification(iError, data && data.ErrorMessage) + || getNotification(Notification.CantSendMessage)); } + } else { + this.closeCommand(); } setFolderHash(this.draftsFolder(), ''); setFolderHash(sSentFolder, ''); @@ -626,21 +624,18 @@ export class ComposePopupView extends AbstractViewPopup { } deleteCommand() { - if (AskPopupView.hidden() && this.modalVisibility()) { - showScreenPopup(AskPopupView, [ - i18n('POPUPS_ASK/DESC_WANT_DELETE_MESSAGES'), - () => { - if (this.modalVisibility()) { - const - sFromFolderFullName = this.draftsFolder(), - aUidForRemove = [this.draftUid()]; - messagesDeleteHelper(sFromFolderFullName, aUidForRemove); - MessagelistUserStore.removeMessagesFromList(sFromFolderFullName, aUidForRemove); - this.closeCommand(); - } - } - ]); - } + AskPopupView.hidden() + && showScreenPopup(AskPopupView, [ + i18n('POPUPS_ASK/DESC_WANT_DELETE_MESSAGES'), + () => { + const + sFromFolderFullName = this.draftsFolder(), + aUidForRemove = [this.draftUid()]; + messagesDeleteHelper(sFromFolderFullName, aUidForRemove); + MessagelistUserStore.removeMessagesFromList(sFromFolderFullName, aUidForRemove); + this.closeCommand(); + } + ]); } onClose() { @@ -652,7 +647,6 @@ export class ComposePopupView extends AbstractViewPopup { this.bSkipNextHide = true; if ( - this.modalVisibility() && !this.saving() && !this.sending() && !FolderUserStore.draftsFolderNotEnabled() && @@ -676,7 +670,7 @@ export class ComposePopupView extends AbstractViewPopup { autosaveStart() { clearTimeout(this.iTimer); this.iTimer = setTimeout(()=>{ - if (this.modalVisibility() + if (this.modalVisible() && !FolderUserStore.draftsFolderNotEnabled() && SettingsUserStore.allowDraftAutosave() && !this.isEmptyForm(false) @@ -1191,7 +1185,7 @@ export class ComposePopupView extends AbstractViewPopup { } tryToClosePopup() { - if (AskPopupView.hidden() && this.modalVisibility()) { + if (AskPopupView.hidden()) { if (this.bSkipNextHide || (this.isEmptyForm() && !this.draftUid())) { this.closeCommand(); } else { @@ -1371,7 +1365,7 @@ export class ComposePopupView extends AbstractViewPopup { const el = doc.getElementById('rl-app'); this.oContent = initFullscreen(el, () => ThemeStore.isMobile() - && this.modalVisibility() + && this.modalVisible() && (getFullscreenElement() !== el) && this.skipCommand() );