Skip to content

Build your personal knowledge base with Trilium Notes

fixes in tree loading

azivner27be3b4c9097
diff --git a/src/public/javascripts/services/tree_cache.js b/src/public/javascripts/services/tree_cache.js
index 3e7582ca66..557d504e78 100644
--- a/src/public/javascripts/services/tree_cache.js
+++ b/src/public/javascripts/services/tree_cache.js
@@ -51,12 +51,12 @@ class TreeCache {
if (!this.notes[noteId]) {
messagingService.logError(`Can't find note ${noteId}`);
- return `[unknown ${noteId}]`;
+ return null;
}
else {
return this.notes[noteId];
}
- });
+ }).filter(note => note !== null);
}
/** @return NoteShort */
diff --git a/src/routes/api/tree.js b/src/routes/api/tree.js
index 2696bd65ea..76d934542b 100644
--- a/src/routes/api/tree.js
+++ b/src/routes/api/tree.js
@@ -35,9 +35,9 @@ async function getTree() {
JOIN tree ON branches.parentNoteId = tree.noteId
WHERE tree.isExpanded = 1 AND branches.isDeleted = 0
)
- SELECT branches.* FROM tree JOIN branches USING(noteId) ORDER BY branches.notePosition`);
+ SELECT branches.* FROM tree JOIN branches USING(noteId) WHERE branches.isDeleted = 0 ORDER BY branches.notePosition`);
- const noteIds = branches.map(b => b.noteId);
+ const noteIds = Array.from(new Set(branches.map(b => b.noteId)));
const notes = await getNotes(noteIds);
diff --git a/src/services/script.js b/src/services/script.js
index 78f69335cb..c820e058d4 100644
--- a/src/services/script.js
+++ b/src/services/script.js
@@ -29,7 +29,7 @@ async function executeBundle(bundle, startNote, originEntity = null) {
return await execute(ctx, script, '');
}
else {
- return await sql.transactional(async () => execute(ctx, script, ''));
+ return await sql.transactional(async () => await execute(ctx, script, ''));
}
}