added contentLength to note entity

This commit is contained in:
zadam
2019-11-09 09:36:08 +01:00
parent 5aa5ec3af1
commit 7c7beb5502
19 changed files with 94 additions and 73 deletions

View File

@@ -21,6 +21,7 @@ const RELATION_DEFINITION = 'relation-definition';
* @property {string} type - one of "text", "code", "file" or "render"
* @property {string} mime - MIME type, e.g. "text/html"
* @property {string} title - note title
* @property {int} contentLength - length of content
* @property {boolean} isProtected - true if note is protected
* @property {boolean} isDeleted - true if note is deleted
* @property {boolean} isErased - true if note's content is erased after it has been deleted
@@ -115,6 +116,7 @@ class Note extends Entity {
async setContent(content) {
// force updating note itself so that dateModified is represented correctly even for the content
this.forcedChange = true;
this.contentLength = content.length;
await this.save();
this.content = content;
@@ -739,6 +741,10 @@ class Note extends Entity {
this.utcDateCreated = dateUtils.utcNowDateTime();
}
if (this.contentLength === undefined) {
this.contentLength = -1;
}
super.beforeSaving();
if (this.isChanged) {