Skip to content

Build your personal knowledge base with Trilium Notes

search fixes

zadam8b0a1e546da4
diff --git a/package-lock.json b/package-lock.json
index 93ecea17e5..f772d2d5b8 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -2634,9 +2634,9 @@
}
},
"electron": {
- "version": "9.4.1",
- "resolved": "https://registry.npmjs.org/electron/-/electron-9.4.1.tgz",
- "integrity": "sha512-r4CxoVG9Ja7tBtkilWMnBsBGup8G8Z+v7icZmwysHa8/OSr0OrLjrcOF/30BAP7yPE5fz/XTxygnltzW4OTZdw==",
+ "version": "11.2.1",
+ "resolved": "https://registry.npmjs.org/electron/-/electron-11.2.1.tgz",
+ "integrity": "sha512-Im1y29Bnil+Nzs+FCTq01J1OtLbs+2ZGLLllaqX/9n5GgpdtDmZhS/++JHBsYZ+4+0n7asO+JKQgJD+CqPClzg==",
"dev": true,
"requires": {
"@electron/get": "^1.0.1",
diff --git a/package.json b/package.json
index 0a8fe50508..59ce57c207 100644
--- a/package.json
+++ b/package.json
@@ -77,7 +77,7 @@
},
"devDependencies": {
"cross-env": "7.0.3",
- "electron": "9.4.1",
+ "electron": "11.2.1",
"electron-builder": "22.9.1",
"electron-packager": "15.2.0",
"electron-rebuild": "2.3.4",
diff --git a/src/public/app/services/tree.js b/src/public/app/services/tree.js
index 68129ba733..4ffa423cda 100644
--- a/src/public/app/services/tree.js
+++ b/src/public/app/services/tree.js
@@ -104,7 +104,7 @@ function getSomeNotePath(note) {
while (cur.noteId !== 'root') {
path.push(cur.noteId);
- const parents = cur.getParentNotes();
+ const parents = cur.getParentNotes().filter(note => note.type !== 'search');
if (!parents.length) {
logError(`Can't find parents for note ${cur.noteId}`);
diff --git a/src/public/app/widgets/note_tree.js b/src/public/app/widgets/note_tree.js
index 00a36daad9..c1a0bdcd03 100644
--- a/src/public/app/widgets/note_tree.js
+++ b/src/public/app/widgets/note_tree.js
@@ -185,6 +185,8 @@ const TPL = `
</div>
`;
+const MAX_SEARCH_RESULTS_IN_TREE = 100;
+
export default class NoteTreeWidget extends TabAwareWidget {
constructor(treeName) {
super();
@@ -480,9 +482,19 @@ export default class NoteTreeWidget extends TabAwareWidget {
}
data.result = treeCache.reloadNotes([noteId]).then(() => {
- const note = treeCache.getNoteFromCache(noteId);
+ const note = treeCache.getNoteFromCache(noteId);
+
+ let childNoteIds = note.getChildNoteIds();
+
+ if (childNoteIds.length > MAX_SEARCH_RESULTS_IN_TREE) {
+ childNoteIds = childNoteIds.slice(0, MAX_SEARCH_RESULTS_IN_TREE);
+ }
+
+ return treeCache.getNotes(childNoteIds);
+ }).then(() => {
+ const note = treeCache.getNoteFromCache(noteId);
- return this.prepareChildren(note);
+ return this.prepareChildren(note);
});
}
else {
@@ -494,6 +506,13 @@ export default class NoteTreeWidget extends TabAwareWidget {
},
enhanceTitle: async function (event, data) {
const node = data.node;
+
+ if (!node.data.noteId) {
+ // if there's "non-note" node, then don't enhance
+ // this can happen for e.g. "Load error!" node
+ return;
+ }
+
const $span = $(node.span);
$span.find('.tree-item-button').remove();
@@ -572,7 +591,13 @@ export default class NoteTreeWidget extends TabAwareWidget {
const hideArchivedNotes = this.hideArchivedNotes;
- for (const branch of this.getChildBranches(parentNote)) {
+ let childBranches = this.getChildBranches(parentNote);
+
+ if (childBranches.length > MAX_SEARCH_RESULTS_IN_TREE) {
+ childBranches = childBranches.slice(0, MAX_SEARCH_RESULTS_IN_TREE);
+ }
+
+ for (const branch of childBranches) {
if (hideArchivedNotes) {
const note = branch.getNoteFromCache();