shortcut improvements

This commit is contained in:
zadam
2022-11-30 16:57:51 +01:00
parent e759b4846a
commit 0985314fb7
10 changed files with 183 additions and 628 deletions

View File

@@ -221,9 +221,15 @@ class Branch extends AbstractEntity {
beforeSaving() {
if (this.notePosition === undefined || this.notePosition === null) {
// TODO finding new position can be refactored into becca
const maxNotePos = sql.getValue('SELECT MAX(notePosition) FROM branches WHERE parentNoteId = ? AND isDeleted = 0', [this.parentNoteId]);
this.notePosition = maxNotePos === null ? 0 : maxNotePos + 10;
let maxNotePos = 0;
for (const childBranch of this.parentNote.getChildBranches()) {
if (maxNotePos < childBranch.notePosition && childBranch.branchId !== 'hidden') {
maxNotePos = childBranch.notePosition;
}
}
this.notePosition = maxNotePos + 10;
}
if (!this.isExpanded) {