Bugfix: subscribables should be created after computables

This commit is contained in:
djmaze 2020-10-26 14:44:34 +01:00
parent f25d210f3e
commit 8d7e25fc7c
3 changed files with 102 additions and 102 deletions

View file

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

View file

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

View file

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