mirror of
https://github.com/zadam/trilium.git
synced 2025-12-05 06:54:23 +01: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");
|
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 () => {
|
it("can restore names in all languages", async () => {
|
||||||
const done = deferred<void>();
|
const done = deferred<void>();
|
||||||
cls.wrap(async () => {
|
cls.wrap(async () => {
|
||||||
|
|||||||
@ -356,9 +356,13 @@ function checkHiddenSubtreeRecursively(parentNoteId: string, item: HiddenSubtree
|
|||||||
} else {
|
} else {
|
||||||
branch = note.getParentBranches().find((branch) => branch.parentNoteId === parentNoteId);
|
branch = note.getParentBranches().find((branch) => branch.parentNoteId === parentNoteId);
|
||||||
|
|
||||||
|
// 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,
|
// 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
|
// create the missing branch to ensure it's in the correct location
|
||||||
if (!branch) {
|
if (!branch) {
|
||||||
|
console.log("Creating missing branch for note", item.id, "under parent", parentNoteId);
|
||||||
branch = new BBranch({
|
branch = new BBranch({
|
||||||
noteId: item.id,
|
noteId: item.id,
|
||||||
parentNoteId: parentNoteId,
|
parentNoteId: parentNoteId,
|
||||||
@ -367,9 +371,7 @@ function checkHiddenSubtreeRecursively(parentNoteId: string, item: HiddenSubtree
|
|||||||
}).save();
|
}).save();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Clean up any branches that shouldn't exist according to the meta definition
|
// Remove any branches that are not in the expected parent.
|
||||||
// For hidden subtree notes, we want to ensure they only exist in their designated locations
|
|
||||||
if (item.enforceBranches || item.id.startsWith("_help")) {
|
|
||||||
const expectedParents = getExpectedParentIds(item.id, hiddenSubtreeDefinition);
|
const expectedParents = getExpectedParentIds(item.id, hiddenSubtreeDefinition);
|
||||||
const currentBranches = note.getParentBranches();
|
const currentBranches = note.getParentBranches();
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user