2020-09-16 22:33:53 +08:00
|
|
|
import { AbstractCollectionModel } from 'Model/AbstractCollection';
|
2020-09-15 21:08:08 +08:00
|
|
|
import { AttachmentModel } from 'Model/Attachment';
|
|
|
|
|
|
|
|
'use strict';
|
|
|
|
|
2020-09-16 22:33:53 +08:00
|
|
|
export class AttachmentCollectionModel extends AbstractCollectionModel
|
2020-09-15 21:08:08 +08:00
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @param {?Array} json
|
|
|
|
* @returns {AttachmentCollectionModel}
|
|
|
|
*/
|
2020-09-20 17:15:00 +08:00
|
|
|
static reviveFromJson(items) {
|
2020-10-23 21:15:54 +08:00
|
|
|
return super.reviveFromJson(items, attachment => AttachmentModel.reviveFromJson(attachment));
|
2021-12-16 22:54:43 +08:00
|
|
|
/*
|
|
|
|
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;
|
|
|
|
*/
|
2020-09-15 21:08:08 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param {string} cid
|
|
|
|
* @returns {*}
|
|
|
|
*/
|
|
|
|
findByCid(cid) {
|
2022-02-02 20:02:48 +08:00
|
|
|
cid = cid.replace(/^<+|>+$/g, '');
|
|
|
|
return this.find(item => cid === item.contentId());
|
2020-09-15 21:08:08 +08:00
|
|
|
}
|
|
|
|
}
|