mirror of
				https://github.com/zadam/trilium.git
				synced 2025-10-31 18:36:30 +01:00 
			
		
		
		
	fixes for undefined parent note #3066
This commit is contained in:
		| @@ -105,7 +105,7 @@ class Branch extends AbstractEntity { | |||||||
|         return this.childNote; |         return this.childNote; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     /** @returns {Note} */ |     /** @returns {Note|undefined} - root branch will have undefined parent, all other branches have to have a parent note */ | ||||||
|     get parentNote() { |     get parentNote() { | ||||||
|         if (!(this.parentNoteId in this.becca.notes) && this.parentNoteId !== 'none') { |         if (!(this.parentNoteId in this.becca.notes) && this.parentNoteId !== 'none') { | ||||||
|             // entities can come out of order in sync/import, create skeleton which will be filled later |             // entities can come out of order in sync/import, create skeleton which will be filled later | ||||||
|   | |||||||
| @@ -699,9 +699,11 @@ class Note extends AbstractEntity { | |||||||
|     sortParents() { |     sortParents() { | ||||||
|         this.parentBranches.sort((a, b) => |         this.parentBranches.sort((a, b) => | ||||||
|             a.branchId.startsWith('virt-') |             a.branchId.startsWith('virt-') | ||||||
|             || a.parentNote.hasInheritableOwnedArchivedLabel() ? 1 : -1); |             || a.parentNote?.hasInheritableOwnedArchivedLabel() ? 1 : -1); | ||||||
|  |  | ||||||
|         this.parents = this.parentBranches.map(branch => branch.parentNote); |         this.parents = this.parentBranches | ||||||
|  |             .map(branch => branch.parentNote) | ||||||
|  |             .filter(note => !!note); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     /** |     /** | ||||||
|   | |||||||
| @@ -281,7 +281,7 @@ async function findSimilarNotes(noteId) { | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     function gatherAncestorRewards(note) { |     function gatherAncestorRewards(note) { | ||||||
|         if (ancestorNoteIds.has(note.noteId)) { |         if (!note || ancestorNoteIds.has(note.noteId)) { | ||||||
|             return 0; |             return 0; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -10,7 +10,7 @@ function getNotesAndBranchesAndAttributes(noteIds) { | |||||||
|     const collectedBranchIds = new Set(); |     const collectedBranchIds = new Set(); | ||||||
|  |  | ||||||
|     function collectEntityIds(note) { |     function collectEntityIds(note) { | ||||||
|         if (collectedNoteIds.has(note.noteId)) { |         if (!note || collectedNoteIds.has(note.noteId)) { | ||||||
|             return; |             return; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user