added ancestor depth search criteria

This commit is contained in:
zadam
2021-01-26 23:25:18 +01:00
parent a1f67e830d
commit fbabdef272
6 changed files with 119 additions and 9 deletions

View File

@@ -368,6 +368,20 @@ class Note {
return arr;
}
getDistanceToAncestor(ancestorNoteId) {
if (this.noteId === ancestorNoteId) {
return 0;
}
let minDistance = 999_999;
for (const parent of this.parents) {
minDistance = Math.min(minDistance, parent.getDistanceToAncestor(ancestorNoteId) + 1);
}
return minDistance;
}
decrypt() {
if (this.isProtected && !this.isDecrypted && protectedSessionService.isProtectedSessionAvailable()) {
this.title = protectedSessionService.decryptString(this.title);