From 4596d56ae884df14ba22197f8fa194cf906b2e84 Mon Sep 17 00:00:00 2001 From: azivner Date: Tue, 12 Dec 2017 22:20:03 -0500 Subject: [PATCH 1/5] fix bug causing non-working autocomplete after creating new note --- public/javascripts/note_tree.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/public/javascripts/note_tree.js b/public/javascripts/note_tree.js index 631322240..393202a3f 100644 --- a/public/javascripts/note_tree.js +++ b/public/javascripts/note_tree.js @@ -614,6 +614,8 @@ const noteTree = (function() { setParentChildRelation(result.note_tree_id, parentNoteId, result.note_id); + notesTreeMap[result.note_tree_id] = result; + noteIdToTitle[result.note_id] = newNoteName; noteEditor.newNoteCreated(); From 513689b175aa2531601ae213746dbbaa7c3b0518 Mon Sep 17 00:00:00 2001 From: azivner Date: Tue, 12 Dec 2017 22:26:40 -0500 Subject: [PATCH 2/5] fix --- public/javascripts/note_tree.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/public/javascripts/note_tree.js b/public/javascripts/note_tree.js index 393202a3f..d6a950902 100644 --- a/public/javascripts/note_tree.js +++ b/public/javascripts/note_tree.js @@ -78,7 +78,8 @@ const noteTree = (function() { } function getNodesByNoteId(noteId) { - return getTree().getNodesByRef(noteId); + const list = getTree().getNodesByRef(noteId); + return list ? list : []; // if no nodes with this refKey are found, fancy tree returns null } function setPrefix(noteTreeId, prefix) { From f71d71104a2137e3e029bfb7499e38ffa5376410 Mon Sep 17 00:00:00 2001 From: azivner Date: Tue, 12 Dec 2017 23:35:41 -0500 Subject: [PATCH 3/5] set db as ready only if migration fully succeeded --- services/migration.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/services/migration.js b/services/migration.js index c663e9703..8748a1cfa 100644 --- a/services/migration.js +++ b/services/migration.js @@ -70,8 +70,6 @@ async function migrate() { await options.setOption("db_version", mig.dbVersion); }); - sql.setDbReadyAsResolved(); - log.info("Migration to version " + mig.dbVersion + " has been successful."); mig['success'] = true; @@ -86,6 +84,10 @@ async function migrate() { } } + if (sql.isDbUpToDate()) { + sql.setDbReadyAsResolved(); + } + return migrations; } From 64e8777ed54d5797780fb77c40483063bc1acb3a Mon Sep 17 00:00:00 2001 From: azivner Date: Tue, 12 Dec 2017 23:39:02 -0500 Subject: [PATCH 4/5] small clarification of the sync logs --- services/sync.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/services/sync.js b/services/sync.js index 1d1e658ad..8eebbdf08 100644 --- a/services/sync.js +++ b/services/sync.js @@ -123,7 +123,7 @@ async function pullSync(syncContext) { for (const sync of syncRows) { if (source_id.isLocalSourceId(sync.source_id)) { - log.info("Skipping " + sync.entity_name + " " + sync.entity_id + " because it has local source id."); + log.info("Skipping pull " + sync.entity_name + " " + sync.entity_id + " because it has local source id."); await setLastSyncedPull(sync.id); @@ -188,7 +188,7 @@ async function pushSync(syncContext) { } if (sync.source_id === syncContext.sourceId) { - log.info("Skipping sync " + sync.entity_name + " " + sync.entity_id + " because it originates from sync target"); + log.info("Skipping push " + sync.entity_name + " " + sync.entity_id + " because it originates from sync target"); } else { await readAndPushEntity(sync, syncContext); From 643069e8d600d2762aca1c783539b5d086a6e669 Mon Sep 17 00:00:00 2001 From: azivner Date: Tue, 12 Dec 2017 23:47:17 -0500 Subject: [PATCH 5/5] sync check failure is now shown as error message in frontend --- public/javascripts/messaging.js | 3 +++ public/javascripts/utils.js | 4 ++-- services/sync.js | 4 +++- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/public/javascripts/messaging.js b/public/javascripts/messaging.js index adcf85565..5a81c3d71 100644 --- a/public/javascripts/messaging.js +++ b/public/javascripts/messaging.js @@ -42,6 +42,9 @@ const messaging = (function() { changesToPushCountEl.html(message.changesToPushCount); } + else if (message.type === 'sync-hash-check-failed') { + showError("Sync check failed!", 60000); + } } function connectWebSocket() { diff --git a/public/javascripts/utils.js b/public/javascripts/utils.js index 000eae89e..4d59a390a 100644 --- a/public/javascripts/utils.js +++ b/public/javascripts/utils.js @@ -17,7 +17,7 @@ function showMessage(message) { }); } -function showError(message) { +function showError(message, delay = 10000) { console.log("error: ", message); $.notify({ @@ -26,7 +26,7 @@ function showError(message) { },{ // settings type: 'danger', - delay: 10000 + delay: delay }); } diff --git a/services/sync.js b/services/sync.js index 8eebbdf08..73c577b96 100644 --- a/services/sync.js +++ b/services/sync.js @@ -4,7 +4,6 @@ const log = require('./log'); const rp = require('request-promise'); const sql = require('./sql'); const options = require('./options'); -const migration = require('./migration'); const utils = require('./utils'); const config = require('./config'); const source_id = require('./source_id'); @@ -14,6 +13,7 @@ const content_hash = require('./content_hash'); const event_log = require('./event_log'); const fs = require('fs'); const app_info = require('./app_info'); +const messaging = require('./messaging'); const SYNC_SERVER = config['Sync']['syncServerHost']; const isSyncSetup = !!SYNC_SERVER; @@ -271,6 +271,8 @@ async function checkContentHash(syncContext) { log.info("Content hash check PASSED with value: " + localContentHash); } else { + await messaging.sendMessage({type: 'sync-hash-check-failed'}); + await event_log.addEvent("Content hash check FAILED. Local is " + localContentHash + ", remote is " + resp.content_hash); } }