mirror of
https://github.com/zadam/trilium.git
synced 2025-06-06 18:08:33 +02:00
speedup of similar notes widget
This commit is contained in:
parent
76dce5197f
commit
a79aec85b5
@ -99,10 +99,6 @@ class TreeCache {
|
|||||||
const resp = await server.post('tree/load', { noteIds: missingNoteIds });
|
const resp = await server.post('tree/load', { noteIds: missingNoteIds });
|
||||||
|
|
||||||
this.addResp(resp.notes, resp.branches, resp.relations);
|
this.addResp(resp.notes, resp.branches, resp.relations);
|
||||||
|
|
||||||
for (const note of resp.notes) {
|
|
||||||
await this.reloadParents(note.noteId);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return noteIds.map(noteId => {
|
return noteIds.map(noteId => {
|
||||||
|
@ -18,7 +18,9 @@ class SimilarNotesWidget extends StandardWidget {
|
|||||||
return;
|
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>');
|
const $list = $('<ul>');
|
||||||
|
|
||||||
@ -29,10 +31,8 @@ class SimilarNotesWidget extends StandardWidget {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
const notePath = await treeService.getSomeNotePath(note);
|
|
||||||
|
|
||||||
const $item = $("<li>")
|
const $item = $("<li>")
|
||||||
.append(await linkService.createNoteLinkWithPath(notePath));
|
.append(await linkService.createNoteLinkWithPath(similarNote.notePath.join("/")));
|
||||||
|
|
||||||
$list.append($item);
|
$list.append($item);
|
||||||
}
|
}
|
||||||
|
@ -348,7 +348,7 @@ function evaluateSimilarity(text1, text2, noteId, results) {
|
|||||||
coeff -= 0.2; // archived penalization
|
coeff -= 0.2; // archived penalization
|
||||||
}
|
}
|
||||||
|
|
||||||
results.push({coeff, noteId});
|
results.push({coeff, notePath, noteId});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user