From 5905950c17791ce0eb278e010c2c8b3450fdb447 Mon Sep 17 00:00:00 2001 From: zadam Date: Mon, 19 Jun 2023 00:29:36 +0200 Subject: [PATCH] fix notePosition assignment for new children of root --- db/migrations/0214__fix_root_children_ordering.sql | 1 + src/services/app_info.js | 2 +- src/services/notes.js | 2 ++ 3 files changed, 4 insertions(+), 1 deletion(-) create mode 100644 db/migrations/0214__fix_root_children_ordering.sql diff --git a/db/migrations/0214__fix_root_children_ordering.sql b/db/migrations/0214__fix_root_children_ordering.sql new file mode 100644 index 000000000..056a76336 --- /dev/null +++ b/db/migrations/0214__fix_root_children_ordering.sql @@ -0,0 +1 @@ +UPDATE branches SET notePosition = notePosition - 999899999 WHERE parentNoteId = 'root' AND notePosition > 999999999; diff --git a/src/services/app_info.js b/src/services/app_info.js index 3f5f02f3b..88338defe 100644 --- a/src/services/app_info.js +++ b/src/services/app_info.js @@ -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"; diff --git a/src/services/notes.js b/src/services/notes.js index c9343bc4e..1ec012186 100644 --- a/src/services/notes.js +++ b/src/services/notes.js @@ -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;