Skip to content

Build your personal knowledge base with Trilium Notes

chore(core): fix references to getHoistedNoteId

Elian Doran321fcf34f25a
diff --git a/apps/server/src/services/cls.ts b/apps/server/src/services/cls.ts
index 4d75ca67d9..8ecb3132ff 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 a5a4001a91..dcd67c7095 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 4c7be548b9..78e8bb199d 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<BBranch> {
}
}
- 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 99cf356653..7f783853c5 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";
+}