modalVisibility() to modalVisible()

This commit is contained in:
the-djmaze 2022-02-26 01:06:18 +01:00
parent 86374433b9
commit 36feca6ce7
3 changed files with 30 additions and 36 deletions

View file

@ -58,9 +58,9 @@ export class AbstractViewPopup extends AbstractView
{ {
super('Popups' + name, ViewType.Popup); super('Popups' + name, ViewType.Popup);
this.keyScope.scope = name; 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, () => { shortcuts.add('escape,close', '', name, () => {
if (this.modalVisibility() && this.onClose()) { if (this.modalVisible() && this.onClose()) {
this.closeCommand(); this.closeCommand();
return false; return false;
} }
@ -90,7 +90,7 @@ AbstractViewPopup.showModal = function(params = []) {
} }
AbstractViewPopup.hidden = function() { AbstractViewPopup.hidden = function() {
return !this.__vm || !this.__vm.modalVisibility(); return !this.__vm || !this.__vm.modalVisible();
} }
export class AbstractViewCenter extends AbstractView export class AbstractViewCenter extends AbstractView

View file

@ -83,7 +83,7 @@ const
} }
}; };
vm.modalVisibility.subscribe(value => { vm.modalVisible.subscribe(value => {
if (value) { if (value) {
visiblePopups.add(vm); visiblePopups.add(vm);
vmDom.style.zIndex = 3000 + (visiblePopups.size * 2); vmDom.style.zIndex = 3000 + (visiblePopups.size * 2);
@ -154,7 +154,7 @@ const
*/ */
hideScreenPopup = ViewModelClassToHide => { hideScreenPopup = ViewModelClassToHide => {
if (ViewModelClassToHide && ViewModelClassToHide.__vm && ViewModelClassToHide.__dom) { 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.onBeforeShow && vm.onBeforeShow(...params);
vm.modalVisibility(true); vm.modalVisible(true);
vm.onShow && vm.onShow(...params); vm.onShow && vm.onShow(...params);
} }

View file

@ -534,19 +534,17 @@ export class ComposePopupView extends AbstractViewPopup {
Remote.request('SendMessage', Remote.request('SendMessage',
(iError, data) => { (iError, data) => {
this.sending(false); this.sending(false);
if (this.modalVisibility()) { if (iError) {
if (iError) { if (Notification.CantSaveMessage === iError) {
if (Notification.CantSaveMessage === iError) { this.sendSuccessButSaveError(true);
this.sendSuccessButSaveError(true); this.savedErrorDesc(i18n('COMPOSE/SAVED_ERROR_ON_SEND').trim());
this.savedErrorDesc(i18n('COMPOSE/SAVED_ERROR_ON_SEND').trim());
} else {
this.sendError(true);
this.sendErrorDesc(getNotification(iError, data && data.ErrorMessage)
|| getNotification(Notification.CantSendMessage));
}
} else { } else {
this.closeCommand(); this.sendError(true);
this.sendErrorDesc(getNotification(iError, data && data.ErrorMessage)
|| getNotification(Notification.CantSendMessage));
} }
} else {
this.closeCommand();
} }
setFolderHash(this.draftsFolder(), ''); setFolderHash(this.draftsFolder(), '');
setFolderHash(sSentFolder, ''); setFolderHash(sSentFolder, '');
@ -626,21 +624,18 @@ export class ComposePopupView extends AbstractViewPopup {
} }
deleteCommand() { deleteCommand() {
if (AskPopupView.hidden() && this.modalVisibility()) { AskPopupView.hidden()
showScreenPopup(AskPopupView, [ && showScreenPopup(AskPopupView, [
i18n('POPUPS_ASK/DESC_WANT_DELETE_MESSAGES'), i18n('POPUPS_ASK/DESC_WANT_DELETE_MESSAGES'),
() => { () => {
if (this.modalVisibility()) { const
const sFromFolderFullName = this.draftsFolder(),
sFromFolderFullName = this.draftsFolder(), aUidForRemove = [this.draftUid()];
aUidForRemove = [this.draftUid()]; messagesDeleteHelper(sFromFolderFullName, aUidForRemove);
messagesDeleteHelper(sFromFolderFullName, aUidForRemove); MessagelistUserStore.removeMessagesFromList(sFromFolderFullName, aUidForRemove);
MessagelistUserStore.removeMessagesFromList(sFromFolderFullName, aUidForRemove); this.closeCommand();
this.closeCommand(); }
} ]);
}
]);
}
} }
onClose() { onClose() {
@ -652,7 +647,6 @@ export class ComposePopupView extends AbstractViewPopup {
this.bSkipNextHide = true; this.bSkipNextHide = true;
if ( if (
this.modalVisibility() &&
!this.saving() && !this.saving() &&
!this.sending() && !this.sending() &&
!FolderUserStore.draftsFolderNotEnabled() && !FolderUserStore.draftsFolderNotEnabled() &&
@ -676,7 +670,7 @@ export class ComposePopupView extends AbstractViewPopup {
autosaveStart() { autosaveStart() {
clearTimeout(this.iTimer); clearTimeout(this.iTimer);
this.iTimer = setTimeout(()=>{ this.iTimer = setTimeout(()=>{
if (this.modalVisibility() if (this.modalVisible()
&& !FolderUserStore.draftsFolderNotEnabled() && !FolderUserStore.draftsFolderNotEnabled()
&& SettingsUserStore.allowDraftAutosave() && SettingsUserStore.allowDraftAutosave()
&& !this.isEmptyForm(false) && !this.isEmptyForm(false)
@ -1191,7 +1185,7 @@ export class ComposePopupView extends AbstractViewPopup {
} }
tryToClosePopup() { tryToClosePopup() {
if (AskPopupView.hidden() && this.modalVisibility()) { if (AskPopupView.hidden()) {
if (this.bSkipNextHide || (this.isEmptyForm() && !this.draftUid())) { if (this.bSkipNextHide || (this.isEmptyForm() && !this.draftUid())) {
this.closeCommand(); this.closeCommand();
} else { } else {
@ -1371,7 +1365,7 @@ export class ComposePopupView extends AbstractViewPopup {
const el = doc.getElementById('rl-app'); const el = doc.getElementById('rl-app');
this.oContent = initFullscreen(el, () => this.oContent = initFullscreen(el, () =>
ThemeStore.isMobile() ThemeStore.isMobile()
&& this.modalVisibility() && this.modalVisible()
&& (getFullscreenElement() !== el) && (getFullscreenElement() !== el)
&& this.skipCommand() && this.skipCommand()
); );