Skip to content

Build your personal knowledge base with Trilium Notes

- changing note parent must change date_modified otherwise it will trigger a conflict - when syncing note tree we don't overwrite is_expanded status

azivner433982e7bc71
diff --git a/routes/api/notes_move.js b/routes/api/notes_move.js
index 453b46cb74..fa2c15d36f 100644
--- a/routes/api/notes_move.js
+++ b/routes/api/notes_move.js
@@ -45,8 +45,10 @@ router.put('/:noteId/moveBefore/:beforeNoteId', async (req, res, next) => {
await sql.execute("update notes_tree set note_pos = note_pos + 1 where note_pid = ? and note_pos >= ? and is_deleted = 0",
[beforeNote['note_pid'], beforeNote['note_pos']]);
- await sql.execute("update notes_tree set note_pid = ?, note_pos = ? where note_id = ?",
- [beforeNote['note_pid'], beforeNote['note_pos'], noteId]);
+ const now = utils.nowTimestamp();
+
+ await sql.execute("update notes_tree set note_pid = ?, note_pos = ?, date_modified = ? where note_id = ?",
+ [beforeNote['note_pid'], beforeNote['note_pos'], now, noteId]);
await sql.addNoteTreeSync(noteId);
await sql.addNoteReorderingSync(beforeNote['note_pid']);
@@ -69,8 +71,10 @@ router.put('/:noteId/moveAfter/:afterNoteId', async (req, res, next) => {
await sql.execute("update notes_tree set note_pos = note_pos + 1 where note_pid = ? and note_pos > ? and is_deleted = 0",
[afterNote['note_pid'], afterNote['note_pos']]);
- await sql.execute("update notes_tree set note_pid = ?, note_pos = ? where note_id = ?",
- [afterNote['note_pid'], afterNote['note_pos'] + 1, noteId]);
+ const now = utils.nowTimestamp();
+
+ await sql.execute("update notes_tree set note_pid = ?, note_pos = ?, date_modified = ? where note_id = ?",
+ [afterNote['note_pid'], afterNote['note_pos'] + 1, now, noteId]);
await sql.addNoteTreeSync(noteId);
await sql.addNoteReorderingSync(afterNote['note_pid']);
diff --git a/services/sync_update.js b/services/sync_update.js
index 6b7bef571d..bfbe1d8c44 100644
--- a/services/sync_update.js
+++ b/services/sync_update.js
@@ -38,6 +38,8 @@ async function updateNoteTree(entity, sourceId) {
if (orig === null || orig.date_modified < entity.date_modified) {
await sql.doInTransaction(async () => {
+ delete entity.is_expanded;
+
await sql.replace('notes_tree', entity);
await sql.addNoteTreeSync(entity.note_id, sourceId);