Skip to content

Commit f809da5

Browse files
committed
fix occurrences of 'root' branch
1 parent ff1f01b commit f809da5

File tree

7 files changed

+9
-8
lines changed

7 files changed

+9
-8
lines changed

spec/search/search.spec.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ describe("Search", () => {
1313
becca.reset();
1414

1515
rootNote = new NoteBuilder(new Note({noteId: 'root', title: 'root', type: 'text'}));
16-
new Branch({branchId: 'root', noteId: 'root', parentNoteId: 'none', notePosition: 10});
16+
new Branch({branchId: 'none_root', noteId: 'root', parentNoteId: 'none', notePosition: 10});
1717
});
1818

1919
it("simple path match", () => {

src/becca/becca_service.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ function getNotePath(noteId) {
180180
let branchId;
181181

182182
if (note.isRoot()) {
183-
branchId = 'root';
183+
branchId = 'none_root';
184184
}
185185
else {
186186
const parentNote = note.parents[0];

src/public/app/services/branches.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ async function moveBeforeBranch(branchIdsToMove, beforeBranchId) {
1010
branchIdsToMove = filterRootNote(branchIdsToMove);
1111
branchIdsToMove = filterSearchBranches(branchIdsToMove);
1212

13-
if (['root', '_lbRoot', '_lbAvailableLaunchers', '_lbVisibleLaunchers'].includes(beforeBranchId)) {
13+
const beforeBranch = await froca.getBranch(beforeBranchId);
14+
15+
if (['root', '_lbRoot', '_lbAvailableLaunchers', '_lbVisibleLaunchers'].includes(beforeBranch.noteId)) {
1416
toastService.showError('Cannot move notes here.');
1517
return;
1618
}

src/public/app/widgets/note_tree.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -637,7 +637,7 @@ export default class NoteTreeWidget extends NoteContextAwareWidget {
637637
}
638638

639639
prepareRootNode() {
640-
return this.prepareNode(froca.getBranch('root'));
640+
return this.prepareNode(froca.getBranch('none_root'));
641641
}
642642

643643
/**

src/routes/api/branches.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ function setExpanded(req) {
143143
const {branchId} = req.params;
144144
const expanded = parseInt(req.params.expanded);
145145

146-
if (branchId !== 'root') {
146+
if (branchId !== 'none_root') {
147147
sql.execute("UPDATE branches SET isExpanded = ? WHERE branchId = ?", [expanded, branchId]);
148148
// we don't sync expanded label
149149
// also this does not trigger updates to the frontend, this would trigger too many reloads
@@ -172,7 +172,7 @@ function setExpandedForSubtree(req) {
172172
SELECT branchId FROM tree`, [branchId]);
173173

174174
// root is always expanded
175-
branchIds = branchIds.filter(branchId => branchId !== 'root');
175+
branchIds = branchIds.filter(branchId => branchId !== 'none_root');
176176

177177
sql.executeMany(`UPDATE branches SET isExpanded = ${expanded} WHERE branchId IN (???)`, branchIds);
178178

src/routes/api/tree.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ function getNotesAndBranchesAndAttributes(noteIds) {
6666

6767
if (noteIds.has('root')) {
6868
branches.push({
69-
branchId: 'root',
69+
branchId: 'none_root',
7070
noteId: 'root',
7171
parentNoteId: 'none',
7272
notePosition: 0,

src/services/sql_init.js

-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ async function createInitialDatabase() {
7777
rootNote.setContent('');
7878

7979
new Branch({
80-
branchId: 'root',
8180
noteId: 'root',
8281
parentNoteId: 'none',
8382
isExpanded: true,

0 commit comments

Comments
 (0)