From 11f69ef9e4abb10b431f1f85cdb13f408c166c83 Mon Sep 17 00:00:00 2001 From: djmaze Date: Wed, 22 Sep 2021 13:37:12 +0200 Subject: [PATCH] Drop popupVisibilityNames/viewModelName in favor of the new visiblePopups Set --- dev/Knoin/AbstractViews.js | 4 +--- dev/Knoin/Knoin.js | 13 ++++++------- dev/View/User/MailBox/MessageList.js | 21 ++++++++++----------- 3 files changed, 17 insertions(+), 21 deletions(-) diff --git a/dev/Knoin/AbstractViews.js b/dev/Knoin/AbstractViews.js index ed4e85901..18dea44af 100644 --- a/dev/Knoin/AbstractViews.js +++ b/dev/Knoin/AbstractViews.js @@ -8,18 +8,15 @@ import { ViewType } from 'Knoin/Knoin'; class AbstractView { constructor(name, templateID, type) { - this.viewModelName = 'View/' + name; this.viewModelTemplateID = templateID; this.viewModelPosition = type; - this.bDisabeCloseOnEsc = false; this.sDefaultScope = Scope.None; this.sCurrentScope = Scope.None; this.viewModelVisible = false; this.modalVisibility = ko.observable(false).extend({ rateLimit: 0 }); - this.viewModelName = ''; this.viewModelDom = null; } @@ -64,6 +61,7 @@ export class AbstractViewPopup extends AbstractView if (name in Scope) { this.sDefaultScope = Scope[name]; } + this.bDisabeCloseOnEsc = false; } /* cancelCommand() {} diff --git a/dev/Knoin/Knoin.js b/dev/Knoin/Knoin.js index 5842abe71..ebd01775c 100644 --- a/dev/Knoin/Knoin.js +++ b/dev/Knoin/Knoin.js @@ -4,7 +4,6 @@ import { doc, $htmlCL } from 'Common/Globals'; import { arrayLength, isFunction } from 'Common/Utils'; let currentScreen = null, - visiblePopups = new Set, defaultScreenName = ''; const SCREENS = {}, @@ -13,6 +12,8 @@ const SCREENS = {}, af && af.focus(); }, + visiblePopups = new Set, + /** * @param {string} screenName * @returns {?Object} @@ -62,10 +63,10 @@ const SCREENS = {}, vm.modalVisibility.subscribe(value => { if (value) { visiblePopups.add(vm); - vmDom.style.zIndex = 3000 + popupVisibilityNames().length + 10; + vmDom.style.zIndex = 3000 + visiblePopups.size + 10; vmDom.hidden = false; vm.storeAndSetScope(); - popupVisibilityNames.push(vm.viewModelName); + arePopupsVisible(true); requestAnimationFrame(() => { // wait just before the next paint vmDom.offsetHeight; // force a reflow vmDom.classList.add('show'); // trigger the transitions @@ -75,7 +76,7 @@ const SCREENS = {}, vm.onHide && vm.onHide(); vmDom.classList.remove('show'); vm.restoreScope(); - popupVisibilityNames(popupVisibilityNames.filter(v=>v!==vm.viewModelName)); + arePopupsVisible(0 < visiblePopups.size); } vmDom.setAttribute('aria-hidden', !value); }); @@ -211,8 +212,6 @@ const SCREENS = {}, }; export const - popupVisibilityNames = ko.observableArray(), - ViewType = { Popup: 'Popups', Left: 'Left', @@ -276,7 +275,7 @@ export const } }, - arePopupsVisible = () => 0 < visiblePopups.size, + arePopupsVisible = ko.observable(false), /** * @param {Function} ViewModelClassToShow diff --git a/dev/View/User/MailBox/MessageList.js b/dev/View/User/MailBox/MessageList.js index 2bace52dd..c16d87651 100644 --- a/dev/View/User/MailBox/MessageList.js +++ b/dev/View/User/MailBox/MessageList.js @@ -39,7 +39,7 @@ import { ThemeStore } from 'Stores/Theme'; import Remote from 'Remote/User/Fetch'; -import { decorateKoCommands, showScreenPopup, popupVisibilityNames } from 'Knoin/Knoin'; +import { decorateKoCommands, showScreenPopup, arePopupsVisible } from 'Knoin/Knoin'; import { AbstractViewRight } from 'Knoin/AbstractViews'; import { FolderClearPopupView } from 'View/Popup/FolderClear'; @@ -74,16 +74,7 @@ export class MessageListMailBoxUserView extends AbstractViewRight { this.messageListSearch = MessageUserStore.listSearch; this.messageListError = MessageUserStore.listError; - this.addComputables({ - popupVisibility: () => 0 < popupVisibilityNames().length, - - folderMenuForMove: () => - folderListOptionsBuilder( - [FolderUserStore.currentFolderFullNameRaw()], - [], - item => item ? item.localName() : '' - ) - }); + this.popupVisibility = arePopupsVisible; this.useCheckboxesInList = SettingsUserStore.useCheckboxesInList; @@ -113,6 +104,14 @@ export class MessageListMailBoxUserView extends AbstractViewRight { this.sLastSearchValue = ''; this.addComputables({ + + folderMenuForMove: () => + folderListOptionsBuilder( + [FolderUserStore.currentFolderFullNameRaw()], + [], + item => item ? item.localName() : '' + ), + messageListSearchDesc: () => { const value = MessageUserStore.listEndSearch(); return value ? i18n('MESSAGE_LIST/SEARCH_RESULT_FOR', { SEARCH: value }) : ''