mirror of
				https://github.com/TriliumNext/Notes.git
				synced 2025-11-04 15:11:31 +08:00 
			
		
		
		
	fix occurrences of 'root' branch
This commit is contained in:
		
							parent
							
								
									ff1f01be8c
								
							
						
					
					
						commit
						f809da58ec
					
				@ -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", () => {
 | 
				
			||||||
 | 
				
			|||||||
@ -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];
 | 
				
			||||||
 | 
				
			|||||||
@ -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;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
				
			|||||||
@ -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'));
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
 | 
				
			|||||||
@ -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);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -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,
 | 
				
			||||||
 | 
				
			|||||||
@ -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,
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user