fixed recent notes

This commit is contained in:
azivner
2017-11-19 12:06:48 -05:00
parent f18d25911b
commit 00151beded
10 changed files with 78 additions and 51 deletions

View File

@@ -4,7 +4,7 @@ const options = require('./options');
const fs = require('fs-extra');
const log = require('./log');
const APP_DB_VERSION = 40;
const APP_DB_VERSION = 41;
const MIGRATIONS_DIR = "migrations";
async function migrate() {

View File

@@ -194,7 +194,7 @@ async function readAndPushEntity(sync, syncContext) {
entity = await sql.getSingleResult('SELECT * FROM options WHERE opt_name = ?', [sync.entity_id]);
}
else if (sync.entity_name === 'recent_notes') {
entity = await sql.getSingleResult('SELECT * FROM recent_notes WHERE note_tree_id = ?', [sync.entity_id]);
entity = await sql.getSingleResult('SELECT * FROM recent_notes WHERE note_path = ?', [sync.entity_id]);
}
else {
throw new Error("Unrecognized entity type " + sync.entity_name);

View File

@@ -22,8 +22,8 @@ async function addOptionsSync(optName, sourceId) {
await addEntitySync("options", optName, sourceId);
}
async function addRecentNoteSync(noteTreeId, sourceId) {
await addEntitySync("recent_notes", noteTreeId, sourceId);
async function addRecentNoteSync(notePath, sourceId) {
await addEntitySync("recent_notes", notePath, sourceId);
}
async function addEntitySync(entityName, entityId, sourceId) {

View File

@@ -106,7 +106,7 @@ async function updateOptions(entity, sourceId) {
}
async function updateRecentNotes(entity, sourceId) {
const orig = await sql.getSingleResultOrNull("select * from recent_notes where note_tree_id = ?", [entity.note_tree_id]);
const orig = await sql.getSingleResultOrNull("select * from recent_notes where note_path = ?", [entity.note_path]);
if (orig === null || orig.date_accessed < entity.date_accessed) {
await sql.doInTransaction(async () => {

View File

@@ -3,11 +3,11 @@
const crypto = require('crypto');
function newNoteId() {
return randomString(12);
return randomString(8);
}
function newNoteTreeId() {
return randomString(8);
return randomString(12);
}
function newNoteHistoryId() {