mirror of
https://github.com/TriliumNext/Notes.git
synced 2026-04-30 09:19:23 -05:00
search (note) fixes
This commit is contained in:
@@ -357,6 +357,7 @@ function initFancyTree(tree) {
|
||||
dnd: dragAndDropSetup,
|
||||
lazyLoad: function(event, data) {
|
||||
const noteId = data.node.data.noteId;
|
||||
|
||||
data.result = treeCache.getNote(noteId).then(note => treeBuilder.prepareBranch(note));
|
||||
},
|
||||
clones: {
|
||||
|
||||
@@ -74,12 +74,17 @@ async function prepareRealBranch(parentNote) {
|
||||
|
||||
async function prepareSearchBranch(note) {
|
||||
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)))
|
||||
.filter(res => res.noteId !== note.noteId); // this is necessary because title of the search note is often the same as the search text which would match and create circle
|
||||
|
||||
const noteIds = results.map(res => res.noteId);
|
||||
|
||||
console.log("result: ", results);
|
||||
|
||||
// force to load all the notes at once instead of one by one
|
||||
await treeCache.getNotes(noteIds);
|
||||
const notes = await treeCache.getNotes(noteIds);
|
||||
|
||||
console.log("NOTES", notes);
|
||||
|
||||
for (const result of results) {
|
||||
const origBranch = await treeCache.getBranch(result.branchId);
|
||||
@@ -95,6 +100,8 @@ async function prepareSearchBranch(note) {
|
||||
treeCache.addBranch(branch);
|
||||
}
|
||||
|
||||
console.log("fullNote", fullNote);
|
||||
|
||||
return await prepareRealBranch(fullNote);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user