mirror of
https://github.com/zadam/trilium.git
synced 2025-06-06 18:08:33 +02:00
minor sync fix for fulltext
This commit is contained in:
parent
896776516b
commit
ae8f4ffbbe
@ -107,6 +107,10 @@ class Note extends Entity {
|
|||||||
|
|
||||||
/** @returns {Promise} */
|
/** @returns {Promise} */
|
||||||
async setContent(content) {
|
async setContent(content) {
|
||||||
|
// force updating note itself so that dateChanged is represented correctly even for the content
|
||||||
|
this.forcedChange = true;
|
||||||
|
await this.save();
|
||||||
|
|
||||||
this.content = content;
|
this.content = content;
|
||||||
|
|
||||||
const pojo = {
|
const pojo = {
|
||||||
@ -128,10 +132,6 @@ class Note extends Entity {
|
|||||||
await sql.upsert("note_contents", "noteId", pojo);
|
await sql.upsert("note_contents", "noteId", pojo);
|
||||||
|
|
||||||
await syncTableService.addNoteContentSync(this.noteId);
|
await syncTableService.addNoteContentSync(this.noteId);
|
||||||
|
|
||||||
this.forcedChange = true;
|
|
||||||
|
|
||||||
await this.save();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @returns {Promise} */
|
/** @returns {Promise} */
|
||||||
|
@ -5,6 +5,11 @@ const html2plaintext = require('html2plaintext');
|
|||||||
const noteIdQueue = [];
|
const noteIdQueue = [];
|
||||||
|
|
||||||
async function updateNoteFulltext(note) {
|
async function updateNoteFulltext(note) {
|
||||||
|
if (!note) {
|
||||||
|
// this might happen when note content is being synced before note itself
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (note.isDeleted || note.isProtected || await note.hasLabel('archived')) {
|
if (note.isDeleted || note.isProtected || await note.hasLabel('archived')) {
|
||||||
await sql.execute(`DELETE
|
await sql.execute(`DELETE
|
||||||
FROM note_fulltext
|
FROM note_fulltext
|
||||||
|
@ -78,10 +78,10 @@ async function updateNoteContent(entity, sourceId) {
|
|||||||
await sql.replace("note_contents", entity);
|
await sql.replace("note_contents", entity);
|
||||||
|
|
||||||
await syncTableService.addNoteContentSync(entity.noteId, sourceId);
|
await syncTableService.addNoteContentSync(entity.noteId, sourceId);
|
||||||
|
|
||||||
noteFulltextService.triggerNoteFulltextUpdate(entity.noteId);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
noteFulltextService.triggerNoteFulltextUpdate(entity.noteId);
|
||||||
|
|
||||||
log.info("Update/sync note content for noteId=" + entity.noteId);
|
log.info("Update/sync note content for noteId=" + entity.noteId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user