snappymail/dev/Model/AttachmentCollection.js

39 lines
962 B
JavaScript
Raw Normal View History

import { AbstractCollectionModel } from 'Model/AbstractCollection';
import { AttachmentModel } from 'Model/Attachment';
'use strict';
export class AttachmentCollectionModel extends AbstractCollectionModel
{
/**
* @param {?Array} json
* @returns {AttachmentCollectionModel}
*/
static reviveFromJson(items) {
2020-10-23 21:15:54 +08:00
return super.reviveFromJson(items, attachment => AttachmentModel.reviveFromJson(attachment));
/*
const attachments = super.reviveFromJson(items, attachment => AttachmentModel.reviveFromJson(attachment));
if (attachments) {
attachments.InlineCount = attachments.reduce((accumulator, a) => accumulator + (a.isInline ? 1 : 0), 0);
}
return attachments;
*/
}
/**
* @returns {boolean}
*/
hasVisible() {
2022-02-11 00:01:36 +08:00
return !!this.filter(item => !item.isLinked()).length;
}
/**
* @param {string} cid
* @returns {*}
*/
findByCid(cid) {
cid = cid.replace(/^<+|>+$/g, '');
return this.find(item => cid === item.contentId());
}
}