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() {
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);

View file

@ -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) {

View file

@ -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()) {

View file

@ -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