fix(help): missing branches if it was relocated

This commit is contained in:
Elian Doran
2025-07-22 18:52:39 +03:00
parent 318f2d1f8c
commit efd9244684

View File

@@ -1,4 +1,5 @@
import BAttribute from "../becca/entities/battribute.js";
import BBranch from "../becca/entities/bbranch.js";
import type { HiddenSubtreeItem } from "@triliumnext/commons";
import becca from "../becca/becca.js";
@@ -313,6 +314,17 @@ function checkHiddenSubtreeRecursively(parentNoteId: string, item: HiddenSubtree
}));
} else {
branch = note.getParentBranches().find((branch) => branch.parentNoteId === parentNoteId);
// If the note exists but doesn't have a branch in the expected parent,
// create the missing branch to ensure it's in the correct location
if (!branch) {
branch = new BBranch({
noteId: item.id,
parentNoteId: parentNoteId,
notePosition: item.notePosition !== undefined ? item.notePosition : undefined,
isExpanded: item.isExpanded !== undefined ? item.isExpanded : false
}).save();
}
}
const attrs = [...(item.attributes || [])];