mirror of
https://github.com/zadam/trilium.git
synced 2025-06-06 18:08:33 +02:00
fixes and optimizations for search
This commit is contained in:
parent
45d9c7164c
commit
e7a504c66b
@ -24,6 +24,12 @@ async function showDialog() {
|
|||||||
},
|
},
|
||||||
minLength: 2
|
minLength: 2
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$autoComplete.autocomplete("instance")._renderItem = function(ul, item) {
|
||||||
|
return $("<li>")
|
||||||
|
.append("<div>" + item.label + "</div>")
|
||||||
|
.appendTo(ul);
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
function getSelectedNotePath() {
|
function getSelectedNotePath() {
|
||||||
|
@ -76,12 +76,19 @@ async function prepareSearchBranch(note) {
|
|||||||
const fullNote = await noteDetailService.loadNote(note.noteId);
|
const fullNote = await noteDetailService.loadNote(note.noteId);
|
||||||
const results = await server.get('search/' + encodeURIComponent(fullNote.jsonContent.searchString));
|
const results = await server.get('search/' + encodeURIComponent(fullNote.jsonContent.searchString));
|
||||||
|
|
||||||
|
const noteIds = results.map(res => res.noteId);
|
||||||
|
|
||||||
|
// force to load all the notes at once instead of one by one
|
||||||
|
await treeCache.getNotes(noteIds);
|
||||||
|
|
||||||
for (const result of results) {
|
for (const result of results) {
|
||||||
|
const origBranch = await treeCache.getBranch(result.branchId);
|
||||||
|
|
||||||
const branch = new Branch(treeCache, {
|
const branch = new Branch(treeCache, {
|
||||||
branchId: "virt" + utils.randomString(10),
|
branchId: "virt" + utils.randomString(10),
|
||||||
noteId: result.noteId,
|
noteId: result.noteId,
|
||||||
parentNoteId: note.noteId,
|
parentNoteId: note.noteId,
|
||||||
prefix: result.prefix,
|
prefix: origBranch.prefix,
|
||||||
virtual: true
|
virtual: true
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ async function getAutocomplete(req) {
|
|||||||
return results.map(res => {
|
return results.map(res => {
|
||||||
return {
|
return {
|
||||||
value: res.title + ' (' + res.path + ')',
|
value: res.title + ' (' + res.path + ')',
|
||||||
title: res.title
|
label: res.title
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -100,8 +100,7 @@ function search(noteId, tokens, path, results) {
|
|||||||
noteId: thisNoteId,
|
noteId: thisNoteId,
|
||||||
branchId: childParentToBranchId[`${thisNoteId}-${thisParentNoteId}`],
|
branchId: childParentToBranchId[`${thisNoteId}-${thisParentNoteId}`],
|
||||||
title: noteTitle,
|
title: noteTitle,
|
||||||
path: retPath.join('/'),
|
path: retPath.join('/')
|
||||||
prefix: prefixes[`${thisNoteId}-${thisParentNoteId}`]
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -206,9 +205,11 @@ function getNotePath(noteId) {
|
|||||||
|
|
||||||
if (retPath) {
|
if (retPath) {
|
||||||
const noteTitle = getNoteTitleForPath(retPath);
|
const noteTitle = getNoteTitleForPath(retPath);
|
||||||
|
const parentNoteId = childToParent[noteId][0];
|
||||||
|
|
||||||
return {
|
return {
|
||||||
noteId: noteId,
|
noteId: noteId,
|
||||||
|
branchId: childParentToBranchId[`${noteId}-${parentNoteId}`],
|
||||||
title: noteTitle,
|
title: noteTitle,
|
||||||
path: retPath.join('/')
|
path: retPath.join('/')
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user