mirror of
https://github.com/zadam/trilium.git
synced 2025-03-01 14:22:32 +01:00
fixes for undefined parent note #3066
This commit is contained in:
parent
78bca2477d
commit
8abcf571e8
@ -105,7 +105,7 @@ class Branch extends AbstractEntity {
|
||||
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() {
|
||||
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
|
||||
|
@ -699,9 +699,11 @@ class Note extends AbstractEntity {
|
||||
sortParents() {
|
||||
this.parentBranches.sort((a, b) =>
|
||||
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) {
|
||||
if (ancestorNoteIds.has(note.noteId)) {
|
||||
if (!note || ancestorNoteIds.has(note.noteId)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -10,7 +10,7 @@ function getNotesAndBranchesAndAttributes(noteIds) {
|
||||
const collectedBranchIds = new Set();
|
||||
|
||||
function collectEntityIds(note) {
|
||||
if (collectedNoteIds.has(note.noteId)) {
|
||||
if (!note || collectedNoteIds.has(note.noteId)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user