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

6
package-lock.json generated
View File

@ -2890,9 +2890,9 @@
}
},
"electron": {
"version": "14.0.0",
"resolved": "https://registry.npmjs.org/electron/-/electron-14.0.0.tgz",
"integrity": "sha512-O6EI7L1BPIrTpEIFefjjmdbmSn9LtE4mmrv4dfpV4Mqaa8uKuNYQogwZPEvSwaBexb69eb1LQ25n+f+kBcjiRQ==",
"version": "13.3.0",
"resolved": "https://registry.npmjs.org/electron/-/electron-13.3.0.tgz",
"integrity": "sha512-d/BvOLDjI4i7yf9tqCuLL2fFGA2TrM/D9PyRpua+rJolG0qrwp/FohP02L0m+44kmPpofIo4l3NPwLmzyKKimA==",
"dev": true,
"requires": {
"@electron/get": "^1.0.1",

View File

@ -81,7 +81,7 @@
},
"devDependencies": {
"cross-env": "7.0.3",
"electron": "14.0.0",
"electron": "13.3.0",
"electron-builder": "22.11.7",
"electron-packager": "15.3.0",
"electron-rebuild": "3.2.3",

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