fix notePosition assignment for new children of root

This commit is contained in:
zadam
2023-06-19 00:29:36 +02:00
parent 691fccb769
commit 5905950c17
3 changed files with 4 additions and 1 deletions

View File

@@ -26,11 +26,13 @@ const fs = require("fs");
function getNewNotePosition(parentNote) {
if (parentNote.isLabelTruthy('newNotesOnTop')) {
const minNotePos = parentNote.getChildBranches()
.filter(branch => branch.noteId !== '_hidden') // has "always last" note position
.reduce((min, note) => Math.min(min, note.notePosition), 0);
return minNotePos - 10;
} else {
const maxNotePos = parentNote.getChildBranches()
.filter(branch => branch.noteId !== '_hidden') // has "always last" note position
.reduce((max, note) => Math.max(max, note.notePosition), 0);
return maxNotePos + 10;