diff --git a/src/becca/entities/abstract_entity.js b/src/becca/entities/abstract_entity.js index 7d9cc7662..f982bf98d 100644 --- a/src/becca/entities/abstract_entity.js +++ b/src/becca/entities/abstract_entity.js @@ -57,6 +57,10 @@ class AbstractEntity { }); } + getPojoToSave() { + return this.getPojo(); + } + save() { const entityName = this.constructor.entityName; const primaryKeyName = this.constructor.primaryKeyName; @@ -67,7 +71,7 @@ class AbstractEntity { this.beforeSaving(); } - const pojo = this.getPojo(); + const pojo = this.getPojoToSave(); sql.transactional(() => { sql.upsert(entityName, primaryKeyName, pojo); diff --git a/src/becca/entities/note.js b/src/becca/entities/note.js index 316f87f5e..f6db3e718 100644 --- a/src/becca/entities/note.js +++ b/src/becca/entities/note.js @@ -1084,7 +1084,7 @@ class Note extends AbstractEntity { } getPojo() { - const pojo = { + return { noteId: this.noteId, title: this.title, isProtected: this.isProtected, @@ -1096,6 +1096,10 @@ class Note extends AbstractEntity { utcDateCreated: this.utcDateCreated, utcDateModified: this.utcDateModified }; + } + + getPojoToSave() { + const pojo = this.getPojo(); if (pojo.isProtected) { if (this.isDecrypted) { diff --git a/src/becca/entities/note_revision.js b/src/becca/entities/note_revision.js index d2eb71378..d90649231 100644 --- a/src/becca/entities/note_revision.js +++ b/src/becca/entities/note_revision.js @@ -156,7 +156,7 @@ class NoteRevision extends AbstractEntity { } getPojo() { - const pojo = { + return { noteRevisionId: this.noteRevisionId, noteId: this.noteId, type: this.type, @@ -169,6 +169,10 @@ class NoteRevision extends AbstractEntity { utcDateCreated: this.utcDateCreated, utcDateModified: this.utcDateModified }; + } + + getPojoToSave() { + const pojo = this.getPojo(); if (pojo.isProtected) { if (protectedSessionService.isProtectedSessionAvailable()) { diff --git a/src/public/app/services/froca_updater.js b/src/public/app/services/froca_updater.js index 5ac97a3d4..11aa7d930 100644 --- a/src/public/app/services/froca_updater.js +++ b/src/public/app/services/froca_updater.js @@ -25,6 +25,8 @@ async function processEntityChanges(entityChanges) { loadResults.addNoteContent(ec.entityId, ec.sourceId); } else if (ec.entityName === 'note_revisions') { loadResults.addNoteRevision(ec.entityId, ec.noteId, ec.sourceId); + } else if (ec.entityName === 'note_revision_contents') { + // this should change only when toggling isProtected, ignore } else if (ec.entityName === 'options') { if (ec.entity.name === 'openTabs') { continue; // only noise