- changing note parent must change date_modified otherwise it will trigger a conflict

- when syncing note tree we don't overwrite is_expanded status
This commit is contained in:
azivner 2017-11-09 21:11:33 -05:00
parent a3b2e705ce
commit 433982e7bc
2 changed files with 10 additions and 4 deletions

View file

@ -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']);

View file

@ -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);