subtree duplication with becca

This commit is contained in:
zadam
2021-04-25 22:02:32 +02:00
parent a5ee590544
commit 93cae44ba0
6 changed files with 50 additions and 16 deletions

View File

@@ -93,14 +93,22 @@ class Note extends AbstractEntity {
return this.parentBranches;
}
getBranches() {
return this.parentBranches;
}
getParentNotes() {
return this.parents;
}
getChildrenNotes() {
getChildNotes() {
return this.children;
}
getChildBranches() {
return this.children.map(childNote => this.becca.getBranch(childNote.noteId, this.noteId));
}
/*
* Note content has quite special handling - it's not a separate entity, but a lazily loaded
* part of Note entity with it's own sync. Reasons behind this hybrid design has been:
@@ -525,6 +533,26 @@ class Note extends AbstractEntity {
return this.getOwnedAttributes(RELATION, name);
}
/**
* @param {string} [type] - (optional) attribute type to filter
* @param {string} [name] - (optional) attribute name to filter
* @returns {Attribute[]} note's "owned" attributes - excluding inherited ones
*/
getOwnedAttributes(type, name) {
if (type && name) {
return this.ownedAttributes.filter(attr => attr.type === type && attr.name === name);
}
else if (type) {
return this.ownedAttributes.filter(attr => attr.type === type);
}
else if (name) {
return this.ownedAttributes.filter(attr => attr.name === name);
}
else {
return this.ownedAttributes.slice();
}
}
get isArchived() {
return this.hasAttribute('label', 'archived');
}
@@ -672,6 +700,10 @@ class Note extends AbstractEntity {
return this.subtreeNotes.map(note => note.noteId);
}
getDescendantNoteIds() {
return this.subtreeNoteIds;
}
get parentCount() {
return this.parents.length;
}
@@ -775,10 +807,6 @@ class Note extends AbstractEntity {
return minDistance;
}
getChildBranches() {
return this.children.map(childNote => this.becca.getBranch(childNote.noteId, this.noteId));
}
decrypt() {
if (this.isProtected && !this.isDecrypted && protectedSessionService.isProtectedSessionAvailable()) {
try {