note cache fixes after refactoring

This commit is contained in:
zadam
2020-05-17 10:11:19 +02:00
parent 60c2049729
commit 32eaafd024
13 changed files with 69 additions and 40 deletions

View File

@@ -1,9 +1,12 @@
"use strict";
const noteCache = require('../note_cache');
const protectedSessionService = require('../../protected_session');
class Note {
constructor(row) {
constructor(noteCache, row) {
/** @param {NoteCache} */
this.noteCache = noteCache;
/** @param {string} */
this.noteId = row.noteId;
/** @param {string} */
@@ -33,7 +36,7 @@ class Note {
this.flatTextCache = null;
if (protectedSessionService.isProtectedSessionAvailable()) {
noteCache.decryptProtectedNote(this);
this.decrypt();
}
}
@@ -52,7 +55,7 @@ class Note {
for (const ownedAttr of parentAttributes) { // parentAttributes so we process also inherited templates
if (ownedAttr.type === 'relation' && ownedAttr.name === 'template') {
const templateNote = notes[ownedAttr.value];
const templateNote = this.noteCache.notes[ownedAttr.value];
if (templateNote) {
templateAttributes.push(...templateNote.attributes);