Skip to content

Build your personal knowledge base with Trilium Notes

fixes

zadam516e6c35da5d
diff --git a/src/public/javascripts/services/tree.js b/src/public/javascripts/services/tree.js
index 75d7040961..39e0ba6fef 100644
--- a/src/public/javascripts/services/tree.js
+++ b/src/public/javascripts/services/tree.js
@@ -294,7 +294,7 @@ function getHashValueFromAddress() {
async function loadTreeData() {
const resp = await server.get('tree');
- treeCache.load(resp.notes, resp.branches);
+ treeCache.load(resp.notes, resp.branches, resp.attributes);
return await treeBuilder.prepareTree();
}
diff --git a/src/public/javascripts/services/tree_cache.js b/src/public/javascripts/services/tree_cache.js
index 6b5468c73e..61604fbadb 100644
--- a/src/public/javascripts/services/tree_cache.js
+++ b/src/public/javascripts/services/tree_cache.js
@@ -1,8 +1,7 @@
import Branch from "../entities/branch.js";
import NoteShort from "../entities/note_short.js";
-import ws from "./ws.js";
-import server from "./server.js";
import Attribute from "../entities/attribute.js";
+import server from "./server.js";
/**
* TreeCache keeps a read only cache of note tree structure in frontend's memory.
@@ -127,7 +126,7 @@ class TreeCache {
async reloadNotes(noteIds) {
const resp = await server.post('tree/load', { noteIds });
- this.addResp(resp.notes, resp.branches);
+ this.addResp(resp.notes, resp.branches, resp.attributes);
for (const note of resp.notes) {
if (note.type === 'search') {
@@ -152,7 +151,7 @@ class TreeCache {
}));
// update this note with standard (parent) branches + virtual (children) branches
- treeCache.addResp([note], branches);
+ treeCache.addResp([note], branches, []);
}
}
}
@@ -167,7 +166,7 @@ class TreeCache {
return noteIds.map(noteId => {
if (!this.notes[noteId] && !silentNotFoundError) {
- ws.logError(`Can't find note "${noteId}"`);
+ console.log(`Can't find note "${noteId}"`);
return null;
}
diff --git a/src/public/javascripts/services/ws.js b/src/public/javascripts/services/ws.js
index 7b7f4aa41e..0b23166e98 100644
--- a/src/public/javascripts/services/ws.js
+++ b/src/public/javascripts/services/ws.js
@@ -1,7 +1,6 @@
import utils from './utils.js';
import toastService from "./toast.js";
import server from "./server.js";
-import appContext from "./app_context.js";
const $outstandingSyncsCount = $("#outstanding-syncs-count");
@@ -133,6 +132,8 @@ async function consumeSyncData() {
const outsideSyncData = allSyncData.filter(sync => sync.sourceId !== glob.sourceId);
try {
+ const appContext = (await import("./app_context.js")).default;
+
// the update process should be synchronous as a whole but individual handlers can run in parallel
await Promise.all([
() => appContext.trigger('syncData', {data: allSyncData}),
diff --git a/src/public/javascripts/widgets/note_tree.js b/src/public/javascripts/widgets/note_tree.js
index 473d7ce28a..526d5facb2 100644
--- a/src/public/javascripts/widgets/note_tree.js
+++ b/src/public/javascripts/widgets/note_tree.js
@@ -560,7 +560,7 @@ export default class NoteTreeWidget extends TabAwareWidget {
});
if (noteIdsToRefresh.size > 0) {
- appContext.trigger('reloadNotes', {noteIds: Array.from(noteIdsToRefresh)});
+ this.appContext.trigger('reloadNotes', {noteIds: Array.from(noteIdsToRefresh)});
}
}
diff --git a/src/routes/api/tree.js b/src/routes/api/tree.js
index 746834bd24..28b8f210f0 100644
--- a/src/routes/api/tree.js
+++ b/src/routes/api/tree.js
@@ -4,7 +4,7 @@ const sql = require('../../services/sql');
const optionService = require('../../services/options');
const treeService = require('../../services/tree');
-async function getNotesAndBranches(noteIds) {
+async function getNotesAndBranchesAndAttributes(noteIds) {
noteIds = Array.from(new Set(noteIds));
const notes = await treeService.getNotes(noteIds);
@@ -45,20 +45,10 @@ async function getNotesAndBranches(noteIds) {
FROM attributes
WHERE isDeleted = 0 AND noteId IN (???)`, noteIds);
- for (const {noteId, type, name, value, isInheritable} of attributes) {
- const note = noteMap[noteId];
-
- note.attributes.push({
- type,
- name,
- value,
- isInheritable
- });
- }
-
return {
branches,
- notes
+ notes,
+ attributes
};
}
@@ -80,11 +70,11 @@ async function getTree() {
noteIds.push('root');
- return await getNotesAndBranches(noteIds);
+ return await getNotesAndBranchesAndAttributes(noteIds);
}
async function load(req) {
- return await getNotesAndBranches(req.body.noteIds);
+ return await getNotesAndBranchesAndAttributes(req.body.noteIds);
}
module.exports = {