Make unsubsribeLinks observable

This commit is contained in:
djmaze 2021-09-01 16:10:44 +02:00
parent 448120b665
commit fa25be0631
2 changed files with 6 additions and 5 deletions

View file

@ -206,7 +206,7 @@ const SCREENS = {},
};
export const
popupVisibilityNames = ko.observableArray([]),
popupVisibilityNames = ko.observableArray(),
ViewType = {
Popup: 'Popups',

View file

@ -84,6 +84,7 @@ export class MessageModel extends AbstractModel {
this.attachments = ko.observableArray(new AttachmentCollectionModel);
this.attachmentsSpecData = ko.observableArray();
this.threads = ko.observableArray();
this.unsubsribeLinks = ko.observableArray();
this.addComputables({
attachmentIconClass: () => FileInfo.getCombinedIconClass(this.hasAttachments() ? this.attachmentsSpecData() : []),
@ -105,7 +106,6 @@ export class MessageModel extends AbstractModel {
this.bcc = new EmailCollectionModel;
this.replyTo = new EmailCollectionModel;
this.deliveredTo = new EmailCollectionModel;
this.unsubsribeLinks = [];
this.body = null;
this.draftInfo = [];
this.messageId = '';
@ -152,6 +152,7 @@ export class MessageModel extends AbstractModel {
this.readReceipt('');
this.threads([]);
this.unsubsribeLinks([]);
this.hasUnseenSubMessage(false);
this.hasFlaggedSubMessage(false);
@ -201,14 +202,14 @@ export class MessageModel extends AbstractModel {
* @returns {boolean}
*/
hasUnsubsribeLinks() {
return this.unsubsribeLinks && this.unsubsribeLinks.length;
return this.unsubsribeLinks().length;
}
/**
* @returns {string}
*/
getFirstUnsubsribeLink() {
return this.unsubsribeLinks && this.unsubsribeLinks.length ? this.unsubsribeLinks[0] || '' : '';
return this.unsubsribeLinks()[0] || '';
}
/**
@ -431,7 +432,7 @@ export class MessageModel extends AbstractModel {
this.bcc = message.bcc;
this.replyTo = message.replyTo;
this.deliveredTo = message.deliveredTo;
this.unsubsribeLinks = message.unsubsribeLinks;
this.unsubsribeLinks(message.unsubsribeLinks);
this.isUnseen(message.isUnseen());
this.isFlagged(message.isFlagged());