Skip to content

Build your personal knowledge base with Trilium Notes

fix occurrences of 'root' branch

zadamf809da58ec9e
diff --git a/spec/search/search.spec.js b/spec/search/search.spec.js
index ce826ed16b..83eba56e72 100644
--- a/spec/search/search.spec.js
+++ b/spec/search/search.spec.js
@@ -13,7 +13,7 @@ describe("Search", () => {
becca.reset();
rootNote = new NoteBuilder(new Note({noteId: 'root', title: 'root', type: 'text'}));
- new Branch({branchId: 'root', noteId: 'root', parentNoteId: 'none', notePosition: 10});
+ new Branch({branchId: 'none_root', noteId: 'root', parentNoteId: 'none', notePosition: 10});
});
it("simple path match", () => {
diff --git a/src/becca/becca_service.js b/src/becca/becca_service.js
index b96296beda..2cb924a5cb 100644
--- a/src/becca/becca_service.js
+++ b/src/becca/becca_service.js
@@ -180,7 +180,7 @@ function getNotePath(noteId) {
let branchId;
if (note.isRoot()) {
- branchId = 'root';
+ branchId = 'none_root';
}
else {
const parentNote = note.parents[0];
diff --git a/src/public/app/services/branches.js b/src/public/app/services/branches.js
index 86eb96c08e..b94c95b2a3 100644
--- a/src/public/app/services/branches.js
+++ b/src/public/app/services/branches.js
@@ -10,7 +10,9 @@ async function moveBeforeBranch(branchIdsToMove, beforeBranchId) {
branchIdsToMove = filterRootNote(branchIdsToMove);
branchIdsToMove = filterSearchBranches(branchIdsToMove);
- if (['root', '_lbRoot', '_lbAvailableLaunchers', '_lbVisibleLaunchers'].includes(beforeBranchId)) {
+ const beforeBranch = await froca.getBranch(beforeBranchId);
+
+ if (['root', '_lbRoot', '_lbAvailableLaunchers', '_lbVisibleLaunchers'].includes(beforeBranch.noteId)) {
toastService.showError('Cannot move notes here.');
return;
}
diff --git a/src/public/app/widgets/note_tree.js b/src/public/app/widgets/note_tree.js
index 2381f23795..3fc6694a7c 100644
--- a/src/public/app/widgets/note_tree.js
+++ b/src/public/app/widgets/note_tree.js
@@ -637,7 +637,7 @@ export default class NoteTreeWidget extends NoteContextAwareWidget {
}
prepareRootNode() {
- return this.prepareNode(froca.getBranch('root'));
+ return this.prepareNode(froca.getBranch('none_root'));
}
/**
diff --git a/src/routes/api/branches.js b/src/routes/api/branches.js
index cb3f31b714..5bc8a3c70b 100644
--- a/src/routes/api/branches.js
+++ b/src/routes/api/branches.js
@@ -143,7 +143,7 @@ function setExpanded(req) {
const {branchId} = req.params;
const expanded = parseInt(req.params.expanded);
- if (branchId !== 'root') {
+ if (branchId !== 'none_root') {
sql.execute("UPDATE branches SET isExpanded = ? WHERE branchId = ?", [expanded, branchId]);
// we don't sync expanded label
// also this does not trigger updates to the frontend, this would trigger too many reloads
@@ -172,7 +172,7 @@ function setExpandedForSubtree(req) {
SELECT branchId FROM tree`, [branchId]);
// root is always expanded
- branchIds = branchIds.filter(branchId => branchId !== 'root');
+ branchIds = branchIds.filter(branchId => branchId !== 'none_root');
sql.executeMany(`UPDATE branches SET isExpanded = ${expanded} WHERE branchId IN (???)`, branchIds);
diff --git a/src/routes/api/tree.js b/src/routes/api/tree.js
index 82b3ace04d..3f9e386a33 100644
--- a/src/routes/api/tree.js
+++ b/src/routes/api/tree.js
@@ -66,7 +66,7 @@ function getNotesAndBranchesAndAttributes(noteIds) {
if (noteIds.has('root')) {
branches.push({
- branchId: 'root',
+ branchId: 'none_root',
noteId: 'root',
parentNoteId: 'none',
notePosition: 0,
diff --git a/src/services/sql_init.js b/src/services/sql_init.js
index 98c78317dc..5ab8c3267f 100644
--- a/src/services/sql_init.js
+++ b/src/services/sql_init.js
@@ -77,7 +77,6 @@ async function createInitialDatabase() {
rootNote.setContent('');
new Branch({
- branchId: 'root',
noteId: 'root',
parentNoteId: 'none',
isExpanded: true,