mirror of
				https://github.com/zadam/trilium.git
				synced 2025-11-04 04:16:17 +01:00 
			
		
		
		
	make sure the sorted branches are still sorted after drag & drop, #2142
This commit is contained in:
		@@ -85,8 +85,6 @@ function moveBranchBeforeNote(req) {
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    entityChangesService.addNoteReorderingEntityChange(beforeBranch.parentNoteId);
 | 
			
		||||
 | 
			
		||||
    if (branchToMove.parentNoteId === beforeBranch.parentNoteId) {
 | 
			
		||||
        branchToMove.notePosition = originalBeforeNotePosition;
 | 
			
		||||
        branchToMove.save();
 | 
			
		||||
@@ -98,6 +96,13 @@ function moveBranchBeforeNote(req) {
 | 
			
		||||
        branchToMove.markAsDeleted();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    if (parentNote.hasLabel('sorted')) {
 | 
			
		||||
        treeService.sortNotesByTitle(parentNote.noteId, false, false);
 | 
			
		||||
    }
 | 
			
		||||
    else {
 | 
			
		||||
        entityChangesService.addNoteReorderingEntityChange(parentNote.noteId);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    return { success: true };
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -129,8 +134,6 @@ function moveBranchAfterNote(req) {
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    entityChangesService.addNoteReorderingEntityChange(afterNote.parentNoteId);
 | 
			
		||||
 | 
			
		||||
    const movedNotePosition = originalAfterNotePosition + 10;
 | 
			
		||||
 | 
			
		||||
    if (branchToMove.parentNoteId === afterNote.parentNoteId) {
 | 
			
		||||
@@ -144,6 +147,13 @@ function moveBranchAfterNote(req) {
 | 
			
		||||
        branchToMove.markAsDeleted();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    if (parentNote.hasLabel('sorted')) {
 | 
			
		||||
        treeService.sortNotesByTitle(parentNote.noteId, false, false);
 | 
			
		||||
    }
 | 
			
		||||
    else {
 | 
			
		||||
        entityChangesService.addNoteReorderingEntityChange(parentNote.noteId);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    return { success: true };
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user