make sure the sorted branches are still sorted after drag & drop, #2142

This commit is contained in:
zadam
2021-09-02 23:21:02 +02:00
parent 167d4816fd
commit 6e300c7cf5
4 changed files with 18 additions and 8 deletions

View File

@@ -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 };
}