search fixes

This commit is contained in:
zadam 2021-01-25 23:43:36 +01:00
parent ec351137d4
commit 8b0a1e546d
4 changed files with 33 additions and 8 deletions

6
package-lock.json generated
View file

@ -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",

View file

@ -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",

View file

@ -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}`);

View file

@ -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);
return this.prepareChildren(note);
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);
});
}
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();