Skip to content

Build your personal knowledge base with Trilium Notes

fix(edit-docs): wrong starting note

Elian Doran112453355791
diff --git a/apps/edit-docs/src/edit-demo.ts b/apps/edit-docs/src/edit-demo.ts
index c2af297a21..f11d68685b 100644
--- a/apps/edit-docs/src/edit-demo.ts
+++ b/apps/edit-docs/src/edit-demo.ts
@@ -31,9 +31,15 @@ async function main() {
async function setOptions() {
const optionsService = (await import("@triliumnext/server/src/services/options.js")).default;
+ const sql = (await import("@triliumnext/server/src/services/sql.js")).default;
+
optionsService.setOption("eraseUnusedAttachmentsAfterSeconds", 10);
optionsService.setOption("eraseUnusedAttachmentsAfterTimeScale", 60);
optionsService.setOption("compressImages", "false");
+
+ // Set initial note to the first visible child of root (not _hidden)
+ const startNoteId = sql.getValue("SELECT noteId FROM branches WHERE parentNoteId = 'root' AND isDeleted = 0 AND noteId != '_hidden' ORDER BY notePosition") || "root";
+ optionsService.setOption("openNoteContexts", JSON.stringify([{ notePath: startNoteId, active: true }]));
}
async function registerHandlers() {
diff --git a/apps/edit-docs/src/edit-docs.ts b/apps/edit-docs/src/edit-docs.ts
index 40163330d0..49846b9eb6 100644
--- a/apps/edit-docs/src/edit-docs.ts
+++ b/apps/edit-docs/src/edit-docs.ts
@@ -141,9 +141,15 @@ async function main() {
async function setOptions() {
const optionsService = (await import("@triliumnext/server/src/services/options.js")).default;
+ const sql = (await import("@triliumnext/server/src/services/sql.js")).default;
+
optionsService.setOption("eraseUnusedAttachmentsAfterSeconds", 10);
optionsService.setOption("eraseUnusedAttachmentsAfterTimeScale", 60);
optionsService.setOption("compressImages", "false");
+
+ // Set initial note to the first visible child of root (not _hidden)
+ const startNoteId = sql.getValue("SELECT noteId FROM branches WHERE parentNoteId = 'root' AND isDeleted = 0 AND noteId != '_hidden' ORDER BY notePosition") || "root";
+ optionsService.setOption("openNoteContexts", JSON.stringify([{ notePath: startNoteId, active: true }]));
}
async function exportData(noteId: string, format: ExportFormat, outputPath: string, ignoredFiles?: Set<string>) {
diff --git a/apps/server/src/services/sql_init.ts b/apps/server/src/services/sql_init.ts
index c6a084a72b..5212cfb6e5 100644
--- a/apps/server/src/services/sql_init.ts
+++ b/apps/server/src/services/sql_init.ts
@@ -141,7 +141,7 @@ async function createInitialDatabase(skipDemoDb?: boolean) {
// the previous solution was to move option initialization here, but then the important parts of initialization
// are not all in one transaction (because ZIP import is async and thus not transactional)
- const startNoteId = sql.getValue("SELECT noteId FROM branches WHERE parentNoteId = 'root' AND isDeleted = 0 ORDER BY notePosition");
+ const startNoteId = sql.getValue("SELECT noteId FROM branches WHERE parentNoteId = 'root' AND isDeleted = 0 AND noteId != '_hidden' ORDER BY notePosition") || "root";
optionService.setOption(
"openNoteContexts",