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

View file

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

View file

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