Some improvements, as found while investigating #322

This commit is contained in:
the-djmaze 2022-04-13 10:48:14 +02:00
parent 5fb78bcd80
commit c5cf9fc71d
3 changed files with 43 additions and 116 deletions

View file

@ -1,4 +1,3 @@
import { pInt } from 'Common/Utils';
import { FileInfo } from 'Common/File';
import { AbstractModel } from 'Knoin/AbstractModel';
@ -59,39 +58,6 @@ export class ComposeAttachmentModel extends AbstractModel {
});
}
static fromAttachment(item)
{
const attachment = new ComposeAttachmentModel(
item.download,
item.fileName,
item.estimatedSize,
item.isInline(),
item.isLinked(),
item.cid,
item.contentLocation
);
attachment.fromMessage = true;
return attachment;
}
/**
* @param {FetchJsonComposeAttachment} json
* @returns {boolean}
*/
initByUploadJson(json) {
let bResult = false;
if (json) {
this.fileName(json.Name);
this.size(undefined === json.Size ? 0 : pInt(json.Size));
this.tempName(undefined === json.TempName ? '' : json.TempName);
this.isInline = false;
bResult = true;
}
return bResult;
}
/**
* @returns {string}
*/