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

@ -0,0 +1 @@
UPDATE branches SET notePosition = notePosition - 999899999 WHERE parentNoteId = 'root' AND notePosition > 999999999;

View File

@ -4,7 +4,7 @@ const build = require('./build');
const packageJson = require('../../package');
const {TRILIUM_DATA_DIR} = require('./data_dir');
const APP_DB_VERSION = 213;
const APP_DB_VERSION = 214;
const SYNC_VERSION = 29;
const CLIPPER_PROTOCOL_VERSION = "1.0";

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;