mirror of
https://github.com/zadam/trilium.git
synced 2025-10-20 07:08:55 +02:00
fix(hidden_subtree): launcher branches created both in visible & available (closes #6537)
This commit is contained in:
parent
384ab1d1f3
commit
425ade5212
@ -83,6 +83,23 @@ describe("Hidden Subtree", () => {
|
||||
expect(updatedJumpToNote?.title).not.toBe("Renamed");
|
||||
});
|
||||
|
||||
it("maintains launchers hidden, if they were shown by default but moved by the user", () => {
|
||||
const launcher = becca.getNote("_lbLlmChat");
|
||||
const branch = launcher?.getParentBranches()[0];
|
||||
expect(branch).toBeDefined();
|
||||
expect(branch!.parentNoteId).toBe("_lbVisibleLaunchers");
|
||||
expect(launcher).toBeDefined();
|
||||
|
||||
cls.init(() => {
|
||||
branches.moveBranchToNote(branch!, "_lbAvailableLaunchers");
|
||||
hiddenSubtreeService.checkHiddenSubtree();
|
||||
});
|
||||
|
||||
const newBranches = launcher?.getParentBranches().filter(b => !b.isDeleted);
|
||||
expect(newBranches).toHaveLength(1);
|
||||
expect(newBranches![0].parentNoteId).toBe("_lbAvailableLaunchers");
|
||||
});
|
||||
|
||||
it("can restore names in all languages", async () => {
|
||||
const done = deferred<void>();
|
||||
cls.wrap(async () => {
|
||||
|
@ -356,20 +356,22 @@ 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();
|
||||
}
|
||||
|
||||
// Clean up any branches that shouldn't exist according to the meta definition
|
||||
// For hidden subtree notes, we want to ensure they only exist in their designated locations
|
||||
if (item.enforceBranches || item.id.startsWith("_help")) {
|
||||
// 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) {
|
||||
console.log("Creating missing branch for note", item.id, "under parent", parentNoteId);
|
||||
branch = new BBranch({
|
||||
noteId: item.id,
|
||||
parentNoteId: parentNoteId,
|
||||
notePosition: item.notePosition !== undefined ? item.notePosition : undefined,
|
||||
isExpanded: item.isExpanded !== undefined ? item.isExpanded : false
|
||||
}).save();
|
||||
}
|
||||
|
||||
// Remove any branches that are not in the expected parent.
|
||||
const expectedParents = getExpectedParentIds(item.id, hiddenSubtreeDefinition);
|
||||
const currentBranches = note.getParentBranches();
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user