Resolve #180 and now works with #89

This commit is contained in:
the-djmaze 2022-02-10 17:01:36 +01:00
parent 25a786d584
commit 2037f21c45
6 changed files with 19 additions and 14 deletions

View file

@ -21,7 +21,6 @@ export class AttachmentModel extends AbstractModel {
this.fileNameExt = ''; this.fileNameExt = '';
this.fileType = FileType.Unknown; this.fileType = FileType.Unknown;
this.friendlySize = ''; this.friendlySize = '';
this.isLinked = false;
this.isThumbnail = false; this.isThumbnail = false;
this.cid = ''; this.cid = '';
this.contentLocation = ''; this.contentLocation = '';
@ -33,7 +32,8 @@ export class AttachmentModel extends AbstractModel {
this.framed = false; this.framed = false;
this.addObservables({ this.addObservables({
isInline: false isInline: false,
isLinked: false
}); });
} }

View file

@ -24,7 +24,7 @@ export class AttachmentCollectionModel extends AbstractCollectionModel
* @returns {boolean} * @returns {boolean}
*/ */
hasVisible() { hasVisible() {
return !!this.find(item => !item.isLinked); return !!this.filter(item => !item.isLinked()).length;
} }
/** /**

View file

@ -65,8 +65,8 @@ export class ComposeAttachmentModel extends AbstractModel {
item.download, item.download,
item.fileName, item.fileName,
item.estimatedSize, item.estimatedSize,
item.isInline, item.isInline(),
item.isLinked, item.isLinked(),
item.cid, item.cid,
item.contentLocation item.contentLocation
); );

View file

@ -397,8 +397,10 @@ export class MessageModel extends AbstractModel {
// Hide valid inline attachments in message view 'attachments' section // Hide valid inline attachments in message view 'attachments' section
oAttachments.forEach(oAttachment => { oAttachments.forEach(oAttachment => {
oAttachment.isLinked = result.foundCIDs.includes(oAttachment.contentId()) let cid = oAttachment.contentId(),
|| result.foundContentLocationUrls.includes(oAttachment.contentLocation) found = result.foundCIDs.includes(cid);
oAttachment.isInline(found);
oAttachment.isLinked(found || result.foundContentLocationUrls.includes(oAttachment.contentLocation));
}); });
this.hasAttachments(oAttachments.hasVisible()); this.hasAttachments(oAttachments.hasVisible());

View file

@ -83,7 +83,7 @@ const
attachment.fileNameExt = ''; attachment.fileNameExt = '';
attachment.fileType = FileType.Unknown; attachment.fileType = FileType.Unknown;
attachment.friendlySize = ''; attachment.friendlySize = '';
attachment.isLinked = false; attachment.isLinked(false);
attachment.isThumbnail = false; attachment.isThumbnail = false;
attachment.contentLocation = ''; attachment.contentLocation = '';
attachment.download = ''; attachment.download = '';
@ -94,11 +94,14 @@ const
*/ */
attachment.cid = cid ? cid.value : ''; attachment.cid = cid ? cid.value : '';
if (cid && html) { if (cid && html) {
let cid = 'cid:' + attachment.contentId(); let cid = 'cid:' + attachment.contentId(),
attachment.isInline(html.includes(cid)); found = html.includes(cid);
html = html 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 + "'"); .replace("src='" + cid + "'", "src='" + attachment.url + "'")
);
} else { } else {
message.attachments.push(attachment); message.attachments.push(attachment);
} }
@ -582,7 +585,7 @@ export class MailMessageView extends AbstractViewRight {
downloadAsZip() { downloadAsZip() {
const hashes = (currentMessage() ? currentMessage().attachments : []) 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); .filter(v => v);
if (hashes.length) { if (hashes.length) {
Remote.attachmentsActions('Zip', hashes, this.downloadAsZipLoading) Remote.attachmentsActions('Zip', hashes, this.downloadAsZipLoading)

View file

@ -221,7 +221,7 @@
css: {'selection-mode' : showAttachmentControls, 'unselectedAttachmentsError': highlightUnselectedAttachments}"> css: {'selection-mode' : showAttachmentControls, 'unselectedAttachmentsError': highlightUnselectedAttachments}">
<ul class="attachmentList" data-bind="foreach: message() ? message().attachments() : []"> <ul class="attachmentList" data-bind="foreach: message() ? message().attachments() : []">
<li class="attachmentItem" draggable="true" <li class="attachmentItem" draggable="true"
data-bind="visible: !isLinked, event: { 'dragstart': eventDragStart }, attr: { 'title': fileName }, css: {'checked': checked}"> data-bind="visible: !isLinked(), event: { 'dragstart': eventDragStart }, attr: { 'title': fileName }, css: {'checked': checked}">
<div class="attachmentIconParent" data-bind="css: { 'hasPreview': hasPreview(), 'hasPreplay': hasPreplay(), 'isImage': isImage() }"> <div class="attachmentIconParent" data-bind="css: { 'hasPreview': hasPreview(), 'hasPreplay': hasPreplay(), 'isImage': isImage() }">
<i class="hidePreview iconMain" data-bind="css: iconClass()"></i> <i class="hidePreview iconMain" data-bind="css: iconClass()"></i>
<div class="showPreview"> <div class="showPreview">