mirror of
https://github.com/zadam/trilium.git
synced 2025-06-06 18:08:33 +02:00
load search result only on explicit action (expand node, execute search), #1759
This commit is contained in:
parent
59e8cb8c8b
commit
6edc6e2825
@ -164,8 +164,16 @@ class TreeCache {
|
|||||||
|
|
||||||
this.addResp(resp);
|
this.addResp(resp);
|
||||||
|
|
||||||
for (const note of resp.notes) {
|
appContext.triggerEvent('notesReloaded', {noteIds});
|
||||||
if (note.type === 'search') {
|
}
|
||||||
|
|
||||||
|
async loadSearchNote(noteId) {
|
||||||
|
const note = await this.getNote(noteId);
|
||||||
|
|
||||||
|
if (!note || note.type !== 'search') {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const searchResultNoteIds = await server.get('search-note/' + note.noteId);
|
const searchResultNoteIds = await server.get('search-note/' + note.noteId);
|
||||||
|
|
||||||
if (!Array.isArray(searchResultNoteIds)) {
|
if (!Array.isArray(searchResultNoteIds)) {
|
||||||
@ -178,7 +186,7 @@ class TreeCache {
|
|||||||
treeCache.notes[note.noteId].childToBranch = {};
|
treeCache.notes[note.noteId].childToBranch = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
const branches = resp.branches.filter(b => b.noteId === note.noteId || b.parentNoteId === note.noteId);
|
const branches = [...note.getBranches(), ...note.getChildBranches()];
|
||||||
|
|
||||||
searchResultNoteIds.forEach((resultNoteId, index) => branches.push({
|
searchResultNoteIds.forEach((resultNoteId, index) => branches.push({
|
||||||
// branchId should be repeatable since sometimes we reload some notes without rerendering the tree
|
// branchId should be repeatable since sometimes we reload some notes without rerendering the tree
|
||||||
@ -198,10 +206,6 @@ class TreeCache {
|
|||||||
|
|
||||||
treeCache.notes[note.noteId].searchResultsLoaded = true;
|
treeCache.notes[note.noteId].searchResultsLoaded = true;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
appContext.triggerEvent('notesReloaded', {noteIds});
|
|
||||||
}
|
|
||||||
|
|
||||||
/** @return {NoteShort[]} */
|
/** @return {NoteShort[]} */
|
||||||
getNotesFromCache(noteIds, silentNotFoundError = false) {
|
getNotesFromCache(noteIds, silentNotFoundError = false) {
|
||||||
|
@ -472,7 +472,7 @@ export default class NoteTreeWidget extends TabAwareWidget {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
data.result = treeCache.reloadNotes([noteId]).then(() => {
|
data.result = treeCache.loadSearchNote(noteId).then(() => {
|
||||||
const note = treeCache.getNoteFromCache(noteId);
|
const note = treeCache.getNoteFromCache(noteId);
|
||||||
|
|
||||||
let childNoteIds = note.getChildNoteIds();
|
let childNoteIds = note.getChildNoteIds();
|
||||||
|
@ -265,7 +265,7 @@ export default class SearchDefinitionWidget extends TabAwareWidget {
|
|||||||
|
|
||||||
async refreshResultsCommand() {
|
async refreshResultsCommand() {
|
||||||
try {
|
try {
|
||||||
await treeCache.reloadNotes([this.noteId]);
|
await treeCache.loadSearchNote(this.noteId);
|
||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
toastService.showError(e.message);
|
toastService.showError(e.message);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user