From 321fcf34f25ac501dd749acfb1b5ae0a30f73d9a Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Tue, 6 Jan 2026 12:29:13 +0200 Subject: [PATCH] chore(core): fix references to getHoistedNoteId --- apps/server/src/services/cls.ts | 4 ++-- packages/trilium-core/src/becca/becca_service.ts | 4 ++-- packages/trilium-core/src/becca/entities/bbranch.ts | 4 ++-- packages/trilium-core/src/services/context.ts | 4 ++++ 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/apps/server/src/services/cls.ts b/apps/server/src/services/cls.ts index 4d75ca67d..8ecb3132f 100644 --- a/apps/server/src/services/cls.ts +++ b/apps/server/src/services/cls.ts @@ -1,5 +1,5 @@ import type { EntityChange } from "@triliumnext/commons"; -import { getContext } from "@triliumnext/core/src/services/context"; +import { getContext, getHoistedNoteId as getHoistedNoteIdInternal } from "@triliumnext/core/src/services/context"; type Callback = (...args: any[]) => any; @@ -18,7 +18,7 @@ function wrap(callback: Callback) { } function getHoistedNoteId() { - return getContext().get("hoistedNoteId") || "root"; + return getHoistedNoteIdInternal(); } function getComponentId() { diff --git a/packages/trilium-core/src/becca/becca_service.ts b/packages/trilium-core/src/becca/becca_service.ts index a5a4001a9..dcd67c709 100644 --- a/packages/trilium-core/src/becca/becca_service.ts +++ b/packages/trilium-core/src/becca/becca_service.ts @@ -2,7 +2,7 @@ import becca from "./becca.js"; import { getLog } from "../services/log.js"; -import { getContext } from "src/services/context.js"; +import { getHoistedNoteId } from "src/services/context.js"; function isNotePathArchived(notePath: string[]) { const noteId = notePath[notePath.length - 1]; @@ -82,7 +82,7 @@ function getNoteTitleArrayForPath(notePathArray: string[]) { let hoistedNotePassed = false; // this is a notePath from outside of hoisted subtree, so the full title path needs to be returned - const hoistedNoteId = getContext().getHoistedNoteId(); + const hoistedNoteId = getHoistedNoteId(); const outsideOfHoistedSubtree = !notePathArray.includes(hoistedNoteId); for (const noteId of notePathArray) { diff --git a/packages/trilium-core/src/becca/entities/bbranch.ts b/packages/trilium-core/src/becca/entities/bbranch.ts index 4c7be548b..78e8bb199 100644 --- a/packages/trilium-core/src/becca/entities/bbranch.ts +++ b/packages/trilium-core/src/becca/entities/bbranch.ts @@ -9,7 +9,7 @@ import TaskContext from "../../services/task_context.js"; import utils from "../../services/utils.js"; import AbstractBeccaEntity from "./abstract_becca_entity.js"; import BNote from "./bnote.js"; -import { getContext } from "src/services/context"; +import { getHoistedNoteId } from "src/services/context"; /** * Branch represents a relationship between a child note and its parent note. Trilium allows a note to have multiple @@ -160,7 +160,7 @@ class BBranch extends AbstractBeccaEntity { } } - if ((this.noteId === "root" || this.noteId === getContext().getHoistedNoteId()) && !this.isWeak) { + if ((this.noteId === "root" || this.noteId === getHoistedNoteId()) && !this.isWeak) { throw new Error("Can't delete root or hoisted branch/note"); } diff --git a/packages/trilium-core/src/services/context.ts b/packages/trilium-core/src/services/context.ts index 99cf35665..7f783853c 100644 --- a/packages/trilium-core/src/services/context.ts +++ b/packages/trilium-core/src/services/context.ts @@ -16,3 +16,7 @@ export function getContext(): ExecutionContext { if (!ctx) throw new Error("Context not initialized"); return ctx; } + +export function getHoistedNoteId() { + return getContext().get("hoistedNoteId") || "root"; +}