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
prevent cycles in resolving the notepath, fixes #1730
zadam09e9ac4d0060
diff --git a/package-lock.json b/package-lock.jsonindex c7ec5ebc1e..aebe0d41f7 100644--- a/package-lock.json+++ b/package-lock.json@@ -1,6 +1,6 @@{"name": "trilium",- "version": "0.46.2-beta",+ "version": "0.46.3-beta","lockfileVersion": 1,"requires": true,"dependencies": {diff --git a/src/public/app/entities/note_short.js b/src/public/app/entities/note_short.jsindex a97b74155a..1cc4fd376c 100644--- a/src/public/app/entities/note_short.js+++ b/src/public/app/entities/note_short.js@@ -254,22 +254,39 @@ class NoteShort {return noteAttributeCache.attributes[this.noteId];}- getAllNotePaths() {+ getAllNotePaths(encounteredNoteIds = null) {if (this.noteId === 'root') {return [['root']];}+ if (!encounteredNoteIds) {+ encounteredNoteIds = new Set();+ }++ encounteredNoteIds.add(this.noteId);+const parentNotes = this.getParentNotes();let paths;if (parentNotes.length === 1) { // optimization for the most common case- paths = parentNotes[0].getAllNotePaths();+ if (encounteredNoteIds.has(parentNotes[0].noteId)) {+ return [];+ }+ else {+ paths = parentNotes[0].getAllNotePaths(encounteredNoteIds);+ }}else {paths = [];for (const parentNote of parentNotes) {- paths.push(...parentNote.getAllNotePaths());+ if (encounteredNoteIds.has(parentNote.noteId)) {+ continue;+ }++ const newSet = new Set(encounteredNoteIds);++ paths.push(...parentNote.getAllNotePaths(newSet));}}