Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
fix infinite cycle when template is descendant of an instance
zadam0040334e89f9
diff --git a/src/public/app/entities/note_short.js b/src/public/app/entities/note_short.jsindex abccf5b87c..45b69d8fdb 100644--- a/src/public/app/entities/note_short.js+++ b/src/public/app/entities/note_short.js@@ -493,11 +493,20 @@ class NoteShort {});}- hasAncestor(ancestorNote) {+ hasAncestor(ancestorNote, visitedNoteIds) {if (this.noteId === ancestorNote.noteId) {return true;}+ if (!visitedNoteIds) {+ visitedNoteIds = new Set();+ } else if (visitedNoteIds.has(this.noteId)) {+ // to avoid infinite cycle when template is descendent of the instance+ return false;+ }++ visitedNoteIds.add(this.noteId);+for (const templateNote of this.getTemplateNotes()) {if (templateNote.hasAncestor(ancestorNote)) {return true;