fix occurrences of 'root' branch

This commit is contained in:
zadam 2022-12-28 13:09:49 +01:00
parent ff1f01be8c
commit f809da58ec
7 changed files with 9 additions and 8 deletions

View File

@ -13,7 +13,7 @@ describe("Search", () => {
becca.reset(); becca.reset();
rootNote = new NoteBuilder(new Note({noteId: 'root', title: 'root', type: 'text'})); 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", () => { it("simple path match", () => {

View File

@ -180,7 +180,7 @@ function getNotePath(noteId) {
let branchId; let branchId;
if (note.isRoot()) { if (note.isRoot()) {
branchId = 'root'; branchId = 'none_root';
} }
else { else {
const parentNote = note.parents[0]; const parentNote = note.parents[0];

View File

@ -10,7 +10,9 @@ async function moveBeforeBranch(branchIdsToMove, beforeBranchId) {
branchIdsToMove = filterRootNote(branchIdsToMove); branchIdsToMove = filterRootNote(branchIdsToMove);
branchIdsToMove = filterSearchBranches(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.'); toastService.showError('Cannot move notes here.');
return; return;
} }

View File

@ -637,7 +637,7 @@ export default class NoteTreeWidget extends NoteContextAwareWidget {
} }
prepareRootNode() { prepareRootNode() {
return this.prepareNode(froca.getBranch('root')); return this.prepareNode(froca.getBranch('none_root'));
} }
/** /**

View File

@ -143,7 +143,7 @@ function setExpanded(req) {
const {branchId} = req.params; const {branchId} = req.params;
const expanded = parseInt(req.params.expanded); const expanded = parseInt(req.params.expanded);
if (branchId !== 'root') { if (branchId !== 'none_root') {
sql.execute("UPDATE branches SET isExpanded = ? WHERE branchId = ?", [expanded, branchId]); sql.execute("UPDATE branches SET isExpanded = ? WHERE branchId = ?", [expanded, branchId]);
// we don't sync expanded label // we don't sync expanded label
// also this does not trigger updates to the frontend, this would trigger too many reloads // 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]); SELECT branchId FROM tree`, [branchId]);
// root is always expanded // 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); sql.executeMany(`UPDATE branches SET isExpanded = ${expanded} WHERE branchId IN (???)`, branchIds);

View File

@ -66,7 +66,7 @@ function getNotesAndBranchesAndAttributes(noteIds) {
if (noteIds.has('root')) { if (noteIds.has('root')) {
branches.push({ branches.push({
branchId: 'root', branchId: 'none_root',
noteId: 'root', noteId: 'root',
parentNoteId: 'none', parentNoteId: 'none',
notePosition: 0, notePosition: 0,

View File

@ -77,7 +77,6 @@ async function createInitialDatabase() {
rootNote.setContent(''); rootNote.setContent('');
new Branch({ new Branch({
branchId: 'root',
noteId: 'root', noteId: 'root',
parentNoteId: 'none', parentNoteId: 'none',
isExpanded: true, isExpanded: true,