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
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2023-01-25 01:58:25 +08:00
|
|
|
* @param {string} cId
|
2020-09-15 21:08:08 +08:00
|
|
|
* @returns {*}
|
|
|
|
*/
|
2023-01-25 01:58:25 +08:00
|
|
|
findByCid(cId) {
|
|
|
|
cId = cId.replace(/^<+|>+$/g, '');
|
|
|
|
return this.find(item => cId === item.contentId());
|
2020-09-15 21:08:08 +08:00
|
|
|
}
|
|
|
|
}
|