Skip to content

Build your personal knowledge base with Trilium Notes

speedup of similar notes widget

zadama79aec85b5d7
diff --git a/src/public/javascripts/services/tree_cache.js b/src/public/javascripts/services/tree_cache.js
index a3fdf203c4..bc70af3b90 100644
--- a/src/public/javascripts/services/tree_cache.js
+++ b/src/public/javascripts/services/tree_cache.js
@@ -99,10 +99,6 @@ class TreeCache {
const resp = await server.post('tree/load', { noteIds: missingNoteIds });
this.addResp(resp.notes, resp.branches, resp.relations);
-
- for (const note of resp.notes) {
- await this.reloadParents(note.noteId);
- }
}
return noteIds.map(noteId => {
diff --git a/src/public/javascripts/widgets/similar_notes.js b/src/public/javascripts/widgets/similar_notes.js
index d56d714c27..c8c08281ad 100644
--- a/src/public/javascripts/widgets/similar_notes.js
+++ b/src/public/javascripts/widgets/similar_notes.js
@@ -18,7 +18,9 @@ class SimilarNotesWidget extends StandardWidget {
return;
}
- await treeCache.getNotes(similarNotes.map(note => note.noteId)); // preload all at once
+ const noteIds = similarNotes.flatMap(note => note.notePath);
+
+ await treeCache.getNotes(noteIds); // preload all at once
const $list = $('<ul>');
@@ -29,10 +31,8 @@ class SimilarNotesWidget extends StandardWidget {
continue;
}
- const notePath = await treeService.getSomeNotePath(note);
-
const $item = $("<li>")
- .append(await linkService.createNoteLinkWithPath(notePath));
+ .append(await linkService.createNoteLinkWithPath(similarNote.notePath.join("/")));
$list.append($item);
}
diff --git a/src/services/note_cache.js b/src/services/note_cache.js
index d5bc91b74c..ba088e33c8 100644
--- a/src/services/note_cache.js
+++ b/src/services/note_cache.js
@@ -348,7 +348,7 @@ function evaluateSimilarity(text1, text2, noteId, results) {
coeff -= 0.2; // archived penalization
}
- results.push({coeff, noteId});
+ results.push({coeff, notePath, noteId});
}
}