diff --git a/dev/Model/Attachment.js b/dev/Model/Attachment.js index dc777a24f..c5522a1dc 100644 --- a/dev/Model/Attachment.js +++ b/dev/Model/Attachment.js @@ -21,7 +21,6 @@ export class AttachmentModel extends AbstractModel { this.fileNameExt = ''; this.fileType = FileType.Unknown; this.friendlySize = ''; - this.isLinked = false; this.isThumbnail = false; this.cid = ''; this.contentLocation = ''; @@ -33,7 +32,8 @@ export class AttachmentModel extends AbstractModel { this.framed = false; this.addObservables({ - isInline: false + isInline: false, + isLinked: false }); } diff --git a/dev/Model/AttachmentCollection.js b/dev/Model/AttachmentCollection.js index 40a0c49ca..b799dc8dc 100644 --- a/dev/Model/AttachmentCollection.js +++ b/dev/Model/AttachmentCollection.js @@ -24,7 +24,7 @@ export class AttachmentCollectionModel extends AbstractCollectionModel * @returns {boolean} */ hasVisible() { - return !!this.find(item => !item.isLinked); + return !!this.filter(item => !item.isLinked()).length; } /** diff --git a/dev/Model/ComposeAttachment.js b/dev/Model/ComposeAttachment.js index 231e1deb4..99f3c87b3 100644 --- a/dev/Model/ComposeAttachment.js +++ b/dev/Model/ComposeAttachment.js @@ -65,8 +65,8 @@ export class ComposeAttachmentModel extends AbstractModel { item.download, item.fileName, item.estimatedSize, - item.isInline, - item.isLinked, + item.isInline(), + item.isLinked(), item.cid, item.contentLocation ); diff --git a/dev/Model/Message.js b/dev/Model/Message.js index a4aa575cb..c89e1d150 100644 --- a/dev/Model/Message.js +++ b/dev/Model/Message.js @@ -397,8 +397,10 @@ export class MessageModel extends AbstractModel { // Hide valid inline attachments in message view 'attachments' section oAttachments.forEach(oAttachment => { - oAttachment.isLinked = result.foundCIDs.includes(oAttachment.contentId()) - || result.foundContentLocationUrls.includes(oAttachment.contentLocation) + let cid = oAttachment.contentId(), + found = result.foundCIDs.includes(cid); + oAttachment.isInline(found); + oAttachment.isLinked(found || result.foundContentLocationUrls.includes(oAttachment.contentLocation)); }); this.hasAttachments(oAttachments.hasVisible()); diff --git a/dev/View/User/MailBox/MessageView.js b/dev/View/User/MailBox/MessageView.js index f03dad77b..2aee5709e 100644 --- a/dev/View/User/MailBox/MessageView.js +++ b/dev/View/User/MailBox/MessageView.js @@ -83,7 +83,7 @@ const attachment.fileNameExt = ''; attachment.fileType = FileType.Unknown; attachment.friendlySize = ''; - attachment.isLinked = false; + attachment.isLinked(false); attachment.isThumbnail = false; attachment.contentLocation = ''; attachment.download = ''; @@ -94,11 +94,14 @@ const */ attachment.cid = cid ? cid.value : ''; if (cid && html) { - let cid = 'cid:' + attachment.contentId(); - attachment.isInline(html.includes(cid)); - html = html + let cid = 'cid:' + attachment.contentId(), + found = html.includes(cid); + attachment.isInline(found); + attachment.isLinked(found); + found && (html = html .replace('src="' + cid + '"', 'src="' + attachment.url + '"') - .replace("src='" + cid + "'", "src='" + attachment.url + "'"); + .replace("src='" + cid + "'", "src='" + attachment.url + "'") + ); } else { message.attachments.push(attachment); } @@ -582,7 +585,7 @@ export class MailMessageView extends AbstractViewRight { downloadAsZip() { const hashes = (currentMessage() ? currentMessage().attachments : []) - .map(item => (item && !item.isLinked && item.checked() ? item.download : '')) + .map(item => (item && !item.isLinked() && item.checked() ? item.download : '')) .filter(v => v); if (hashes.length) { Remote.attachmentsActions('Zip', hashes, this.downloadAsZipLoading) diff --git a/snappymail/v/0.0.0/app/templates/Views/User/MailMessageView.html b/snappymail/v/0.0.0/app/templates/Views/User/MailMessageView.html index 616e2e103..ed9408caf 100644 --- a/snappymail/v/0.0.0/app/templates/Views/User/MailMessageView.html +++ b/snappymail/v/0.0.0/app/templates/Views/User/MailMessageView.html @@ -221,7 +221,7 @@ css: {'selection-mode' : showAttachmentControls, 'unselectedAttachmentsError': highlightUnselectedAttachments}">