From efd9244684377b0d3327940aec55f3fafcd12c18 Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Tue, 22 Jul 2025 18:52:39 +0300 Subject: [PATCH] fix(help): missing branches if it was relocated --- apps/server/src/services/hidden_subtree.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/apps/server/src/services/hidden_subtree.ts b/apps/server/src/services/hidden_subtree.ts index 8b6c7e9fb..3c6291ded 100644 --- a/apps/server/src/services/hidden_subtree.ts +++ b/apps/server/src/services/hidden_subtree.ts @@ -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 || [])];