autocomplete cache gets updated with note update

This commit is contained in:
azivner
2018-04-18 23:11:30 -04:00
parent 834bfa39c7
commit bbf04209f0
2 changed files with 28 additions and 0 deletions

View File

@@ -5,6 +5,12 @@ const syncSetup = require('./sync_setup');
const log = require('./log');
const cls = require('./cls');
const listeners = [];
function addListener(listener) {
listeners.push(listener);
}
async function addNoteSync(noteId, sourceId) {
await addEntitySync("notes", noteId, sourceId)
}
@@ -58,6 +64,11 @@ async function addEntitySync(entityName, entityId, sourceId) {
// useful when you fork the DB for new "client" instance, it won't try to sync the whole DB
await sql.execute("UPDATE options SET value = (SELECT MAX(id) FROM sync) WHERE name IN('lastSyncedPush', 'lastSyncedPull')");
}
for (const listener of listeners) {
// not awaiting to not block the execution
listener(entityName, entityId);
}
}
async function cleanupSyncRowsForMissingEntities(entityName, entityKey) {
@@ -104,6 +115,7 @@ async function fillAllSyncRows() {
}
module.exports = {
addListener,
addNoteSync,
addBranchSync,
addNoteReorderingSync,