From 8d7e25fc7c6cf1b815b148fdf0741456c58dc888 Mon Sep 17 00:00:00 2001 From: djmaze Date: Mon, 26 Oct 2020 14:44:34 +0100 Subject: [PATCH] Bugfix: subscribables should be created after computables --- dev/View/Popup/Contacts.js | 16 ++--- dev/View/Popup/Domain.js | 92 +++++++++++++------------- dev/View/User/MailBox/MessageView.js | 96 ++++++++++++++-------------- 3 files changed, 102 insertions(+), 102 deletions(-) diff --git a/dev/View/Popup/Contacts.js b/dev/View/Popup/Contacts.js index eca63b4ff..d7cdbe42f 100644 --- a/dev/View/Popup/Contacts.js +++ b/dev/View/Popup/Contacts.js @@ -94,8 +94,6 @@ class ContactsPopupView extends AbstractViewNext { this.useCheckboxesInList = SettingsStore.useCheckboxesInList; - this.search.subscribe(() => this.reloadContactList()); - this.selector = new Selector( this.contacts, this.currentContact, @@ -119,12 +117,6 @@ class ContactsPopupView extends AbstractViewNext { // this.saveCommandDebounce = _.debounce(this.saveCommand.bind(this), 1000); - this.viewHash.subscribe(() => { - if (this.watchHash() && !this.viewReadOnly() && !this.watchDirty()) { - this.watchDirty(true); - } - }); - this.sDefaultKeyScope = KeyState.ContactList; this.addComputables({ @@ -181,6 +173,14 @@ class ContactsPopupView extends AbstractViewNext { viewHash: () => '' + this.viewProperties().map(oItem => oItem.value()).join('') }); + + this.search.subscribe(() => this.reloadContactList()); + + this.viewHash.subscribe(() => { + if (this.watchHash() && !this.viewReadOnly() && !this.watchDirty()) { + this.watchDirty(true); + } + }); } @command() diff --git a/dev/View/Popup/Domain.js b/dev/View/Popup/Domain.js index a46f783a0..4923a11e0 100644 --- a/dev/View/Popup/Domain.js +++ b/dev/View/Popup/Domain.js @@ -60,6 +60,52 @@ class DomainPopupView extends AbstractViewNext { enableSmartPorts: false }); + this.addComputables({ + allowSieve: () => CapaAdminStore.filters() && CapaAdminStore.sieve(), + + headerText: () => { + const name = this.name(), + aliasName = this.aliasName(); + + let result = ''; + + if (this.edit()) { + result = i18n('POPUPS_DOMAIN/TITLE_EDIT_DOMAIN', { 'NAME': name }); + if (aliasName) { + result += ' ← ' + aliasName; + } + } else { + result = name + ? i18n('POPUPS_DOMAIN/TITLE_ADD_DOMAIN_WITH_NAME', { 'NAME': name }) + : i18n('POPUPS_DOMAIN/TITLE_ADD_DOMAIN'); + } + + return result; + }, + + domainDesc: () => { + const name = this.name(); + return !this.edit() && name ? i18n('POPUPS_DOMAIN/NEW_DOMAIN_DESC', { 'NAME': '*@' + name }) : ''; + }, + + domainIsComputed: () => { + const usePhpMail = this.smtpPhpMail(), + allowSieve = this.allowSieve(), + useSieve = this.useSieve(); + + return ( + this.name() && + this.imapServer() && + this.imapPort() && + (allowSieve && useSieve ? this.sieveServer() && this.sievePort() : true) && + ((this.smtpServer() && this.smtpPort()) || usePhpMail) + ); + }, + + canBeTested: () => !this.testing() && this.domainIsComputed(), + canBeSaved: () => !this.saving() && this.domainIsComputed() + }); + this.addSubscribables({ testingImapError: value => value || this.testingImapErrorDesc(''), testingSieveError: value => value || this.testingSieveErrorDesc(''), @@ -121,52 +167,6 @@ class DomainPopupView extends AbstractViewNext { } } }); - - this.addComputables({ - allowSieve: () => CapaAdminStore.filters() && CapaAdminStore.sieve(), - - headerText: () => { - const name = this.name(), - aliasName = this.aliasName(); - - let result = ''; - - if (this.edit()) { - result = i18n('POPUPS_DOMAIN/TITLE_EDIT_DOMAIN', { 'NAME': name }); - if (aliasName) { - result += ' ← ' + aliasName; - } - } else { - result = name - ? i18n('POPUPS_DOMAIN/TITLE_ADD_DOMAIN_WITH_NAME', { 'NAME': name }) - : i18n('POPUPS_DOMAIN/TITLE_ADD_DOMAIN'); - } - - return result; - }, - - domainDesc: () => { - const name = this.name(); - return !this.edit() && name ? i18n('POPUPS_DOMAIN/NEW_DOMAIN_DESC', { 'NAME': '*@' + name }) : ''; - }, - - domainIsComputed: () => { - const usePhpMail = this.smtpPhpMail(), - allowSieve = this.allowSieve(), - useSieve = this.useSieve(); - - return ( - this.name() && - this.imapServer() && - this.imapPort() && - (allowSieve && useSieve ? this.sieveServer() && this.sievePort() : true) && - ((this.smtpServer() && this.smtpPort()) || usePhpMail) - ); - }, - - canBeTested: () => !this.testing() && this.domainIsComputed(), - canBeSaved: () => !this.saving() && this.domainIsComputed() - }); } @command((self) => self.canBeSaved()) diff --git a/dev/View/User/MailBox/MessageView.js b/dev/View/User/MailBox/MessageView.js index 40e7ba270..3a23b8327 100644 --- a/dev/View/User/MailBox/MessageView.js +++ b/dev/View/User/MailBox/MessageView.js @@ -159,6 +159,54 @@ class MessageViewMailBoxUserView extends AbstractViewNext { viewIsFlagged: false }); + this.addComputables({ + allowAttachmnetControls: () => this.attachmentsActions().length && Settings.capa(Capa.AttachmentsActions), + + downloadAsZipAllowed: () => this.attachmentsActions().includes('zip') && this.allowAttachmnetControls(), + + lastReplyAction: { + read: this.lastReplyAction_, + write: value => this.lastReplyAction_( + [ComposeType.Reply, ComposeType.ReplyAll, ComposeType.Forward].includes(value) + ? ComposeType.Reply + : value + ) + }, + + messageVisibility: () => !this.messageLoadingThrottle() && !!this.message(), + + canBeRepliedOrForwarded: () => !this.isDraftFolder() && this.messageVisibility(), + + viewFromDkimVisibility: () => 'none' !== this.viewFromDkimData()[0], + + viewFromDkimStatusIconClass:() => { + switch (this.viewFromDkimData()[0]) { + case 'none': + return 'icon-none iconcolor-display-none'; + case 'pass': + return 'icon-ok iconcolor-green'; + default: + return 'icon-warning-alt iconcolor-red'; + } + }, + + viewFromDkimStatusTitle:() => { + const status = this.viewFromDkimData(); + if (Array.isNotEmpty(status)) { + if (status[0]) { + return status[1] || 'DKIM: ' + status[0]; + } + } + + return ''; + }, + + messageFocused: () => Focused.MessageView === AppStore.focusedState(), + + messageListAndMessageViewLoading: + () => MessageStore.messageListCompleteLoadingThrottle() || MessageStore.messageLoadingThrottle() + }); + this.addSubscribables({ showAttachmnetControls: v => this.message() && this.message().attachments().forEach(item => item && item.checked(!!v)), @@ -221,54 +269,6 @@ class MessageViewMailBoxUserView extends AbstractViewNext { message ? this.viewIsFlagged(message.isFlagged()) : this.viewIsFlagged(false); }); - this.addComputables({ - allowAttachmnetControls: () => this.attachmentsActions().length && Settings.capa(Capa.AttachmentsActions), - - downloadAsZipAllowed: () => this.attachmentsActions().includes('zip') && this.allowAttachmnetControls(), - - lastReplyAction: { - read: this.lastReplyAction_, - write: value => this.lastReplyAction_( - [ComposeType.Reply, ComposeType.ReplyAll, ComposeType.Forward].includes(value) - ? ComposeType.Reply - : value - ) - }, - - messageVisibility: () => !this.messageLoadingThrottle() && !!this.message(), - - canBeRepliedOrForwarded: () => !this.isDraftFolder() && this.messageVisibility(), - - viewFromDkimVisibility: () => 'none' !== this.viewFromDkimData()[0], - - viewFromDkimStatusIconClass:() => { - switch (this.viewFromDkimData()[0]) { - case 'none': - return 'icon-none iconcolor-display-none'; - case 'pass': - return 'icon-ok iconcolor-green'; - default: - return 'icon-warning-alt iconcolor-red'; - } - }, - - viewFromDkimStatusTitle:() => { - const status = this.viewFromDkimData(); - if (Array.isNotEmpty(status)) { - if (status[0]) { - return status[1] || 'DKIM: ' + status[0]; - } - } - - return ''; - }, - - messageFocused: () => Focused.MessageView === AppStore.focusedState(), - - messageListAndMessageViewLoading: - () => MessageStore.messageListCompleteLoadingThrottle() || MessageStore.messageLoadingThrottle() - }); - this.lastReplyAction(Local.get(ClientSideKeyName.LastReplyAction) || ComposeType.Reply); addEventListener('mailbox.message-view.toggle-full-screen', () => this.toggleFullScreen());