note content refactoring, WIP

This commit is contained in:
zadam
2019-02-06 21:29:23 +01:00
parent 8884177d9f
commit c487a95bc7
17 changed files with 158 additions and 123 deletions

View File

@@ -67,6 +67,13 @@ class Note extends Entity {
return this.noteContent;
}
/** @returns {Promise<*>} */
async getContent() {
const noteContent = await this.getNoteContent();
return noteContent.content;
}
/** @returns {boolean} true if this note is the root of the note tree. Root note has "root" noteId */
isRoot() {
return this.noteId === 'root';
@@ -606,10 +613,6 @@ class Note extends Entity {
}
beforeSaving() {
if (this.isJson() && this.jsonContent) {
this.content = JSON.stringify(this.jsonContent, null, '\t');
}
// we do this here because encryption needs the note ID for the IV
this.generateIdIfNecessary();
@@ -637,7 +640,6 @@ class Note extends Entity {
else {
// updating protected note outside of protected session means we will keep original ciphertexts
pojo.title = pojo.titleCipherText;
pojo.content = pojo.contentCipherText;
}
}
@@ -645,7 +647,6 @@ class Note extends Entity {
delete pojo.isContentAvailable;
delete pojo.__attributeCache;
delete pojo.titleCipherText;
delete pojo.contentCipherText;
}
}