fix in passing originEntity from frontend to backend, some refactorings

This commit is contained in:
azivner
2018-08-16 23:00:04 +02:00
parent 385d97a9b3
commit 208771216e
14 changed files with 36 additions and 24 deletions

View File

@@ -6,7 +6,17 @@ import messagingService from "./messaging.js";
import server from "./server.js";
class TreeCache {
constructor() {
this.init();
}
load(noteRows, branchRows, relations) {
this.init();
this.addResp(noteRows, branchRows, relations);
}
init() {
this.parents = {};
this.children = {};
this.childParentToBranch = {};
@@ -16,8 +26,6 @@ class TreeCache {
/** @type {Object.<string, Branch>} */
this.branches = {};
this.addResp(noteRows, branchRows, relations);
}
addResp(noteRows, branchRows, relations) {
@@ -38,7 +46,7 @@ class TreeCache {
}
}
async getNotes(noteIds) {
async getNotes(noteIds, silentNotFoundError = false) {
const missingNoteIds = noteIds.filter(noteId => this.notes[noteId] === undefined);
if (missingNoteIds.length > 0) {
@@ -48,7 +56,7 @@ class TreeCache {
}
return noteIds.map(noteId => {
if (!this.notes[noteId]) {
if (!this.notes[noteId] && !silentNotFoundError) {
messagingService.logError(`Can't find note ${noteId}`);
return null;