fix toggling protected flag and display of the title

This commit is contained in:
zadam 2021-09-08 22:35:32 +02:00
parent 151687cd9b
commit 010f075ac5
4 changed files with 17 additions and 3 deletions

View File

@ -57,6 +57,10 @@ class AbstractEntity {
}); });
} }
getPojoToSave() {
return this.getPojo();
}
save() { save() {
const entityName = this.constructor.entityName; const entityName = this.constructor.entityName;
const primaryKeyName = this.constructor.primaryKeyName; const primaryKeyName = this.constructor.primaryKeyName;
@ -67,7 +71,7 @@ class AbstractEntity {
this.beforeSaving(); this.beforeSaving();
} }
const pojo = this.getPojo(); const pojo = this.getPojoToSave();
sql.transactional(() => { sql.transactional(() => {
sql.upsert(entityName, primaryKeyName, pojo); sql.upsert(entityName, primaryKeyName, pojo);

View File

@ -1084,7 +1084,7 @@ class Note extends AbstractEntity {
} }
getPojo() { getPojo() {
const pojo = { return {
noteId: this.noteId, noteId: this.noteId,
title: this.title, title: this.title,
isProtected: this.isProtected, isProtected: this.isProtected,
@ -1096,6 +1096,10 @@ class Note extends AbstractEntity {
utcDateCreated: this.utcDateCreated, utcDateCreated: this.utcDateCreated,
utcDateModified: this.utcDateModified utcDateModified: this.utcDateModified
}; };
}
getPojoToSave() {
const pojo = this.getPojo();
if (pojo.isProtected) { if (pojo.isProtected) {
if (this.isDecrypted) { if (this.isDecrypted) {

View File

@ -156,7 +156,7 @@ class NoteRevision extends AbstractEntity {
} }
getPojo() { getPojo() {
const pojo = { return {
noteRevisionId: this.noteRevisionId, noteRevisionId: this.noteRevisionId,
noteId: this.noteId, noteId: this.noteId,
type: this.type, type: this.type,
@ -169,6 +169,10 @@ class NoteRevision extends AbstractEntity {
utcDateCreated: this.utcDateCreated, utcDateCreated: this.utcDateCreated,
utcDateModified: this.utcDateModified utcDateModified: this.utcDateModified
}; };
}
getPojoToSave() {
const pojo = this.getPojo();
if (pojo.isProtected) { if (pojo.isProtected) {
if (protectedSessionService.isProtectedSessionAvailable()) { if (protectedSessionService.isProtectedSessionAvailable()) {

View File

@ -25,6 +25,8 @@ async function processEntityChanges(entityChanges) {
loadResults.addNoteContent(ec.entityId, ec.sourceId); loadResults.addNoteContent(ec.entityId, ec.sourceId);
} else if (ec.entityName === 'note_revisions') { } else if (ec.entityName === 'note_revisions') {
loadResults.addNoteRevision(ec.entityId, ec.noteId, ec.sourceId); 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') { } else if (ec.entityName === 'options') {
if (ec.entity.name === 'openTabs') { if (ec.entity.name === 'openTabs') {
continue; // only noise continue; // only noise