From cf45594d89310d27c35b819badc1b89e74eed805 Mon Sep 17 00:00:00 2001 From: azivner Date: Fri, 3 Nov 2017 20:50:48 -0400 Subject: [PATCH] don't alert in case of updated note in current editor --- public/javascripts/status.js | 5 +---- routes/api/notes.js | 2 +- services/sync.js | 2 +- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/public/javascripts/status.js b/public/javascripts/status.js index 71104ef4d..205e8f08e 100644 --- a/public/javascripts/status.js +++ b/public/javascripts/status.js @@ -13,14 +13,11 @@ function checkStatus() { loadTree().then(resp => { console.log("Reloading tree because of background changes"); + // this will also reload the note content globalTree.fancytree('getTree').reload(resp.notes); }); } - if (resp.changedCurrentNote) { - alert("Current note has been changed in different window / computer. Please reload the application and resolve the conflict manually."); - } - $("#changesToPushCount").html(resp.changesToPushCount); }, statusCode: { diff --git a/routes/api/notes.js b/routes/api/notes.js index 3a3a7b34b..006a6d013 100644 --- a/routes/api/notes.js +++ b/routes/api/notes.js @@ -11,7 +11,7 @@ const auth = require('../../services/auth'); router.get('/:noteId', auth.checkApiAuth, async (req, res, next) => { let noteId = req.params.noteId; - await sql.execute("update options set opt_value = ? where opt_name = 'start_node'", [noteId]); + await options.setOption('start_node', noteId); let detail = await sql.getSingleResult("select * from notes where note_id = ?", [noteId]); diff --git a/services/sync.js b/services/sync.js index 63c5f9723..2ad89d251 100644 --- a/services/sync.js +++ b/services/sync.js @@ -253,7 +253,7 @@ function logSyncError(message, e, syncLog) { async function updateNote(entity, links, sourceId, syncLog) { const origNote = await sql.getSingleResult("select * from notes where note_id = ?", [entity.note_id]); - if (origNote === null || origNote.date_modified <= entity.date_modified) { + if (!origNote || origNote.date_modified <= entity.date_modified) { await sql.doInTransaction(async () => { await sql.replace("notes", entity);