mirror of
https://github.com/zadam/trilium.git
synced 2025-06-06 18:08:33 +02:00
limit number of results to 200, other tweaks
This commit is contained in:
parent
52b445f70b
commit
834bfa39c7
@ -42,30 +42,49 @@ function getResults(query) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
results.sort((a, b) => a.title < b.title ? -1 : 1);
|
||||||
|
|
||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
function search(noteIds, tokens, path, results) {
|
function search(noteIds, tokens, path, results) {
|
||||||
if (!noteIds) {
|
if (!noteIds || noteIds.length === 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tokens.length === 0) {
|
||||||
|
let curNoteId = noteIds[0];
|
||||||
|
|
||||||
|
while (curNoteId !== 'root') {
|
||||||
|
path.push(curNoteId);
|
||||||
|
|
||||||
|
const parents = childToParent[curNoteId];
|
||||||
|
|
||||||
|
if (!parents || parents.length === 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
curNoteId = parents[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
path.reverse();
|
||||||
|
|
||||||
|
const noteTitle = getNoteTitle(path);
|
||||||
|
|
||||||
|
results.push({
|
||||||
|
title: noteTitle,
|
||||||
|
path: path.join('/')
|
||||||
|
});
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const noteId of noteIds) {
|
for (const noteId of noteIds) {
|
||||||
if (noteId === 'root') {
|
if (results.length >= 200) {
|
||||||
if (tokens.length === 0) {
|
return;
|
||||||
const reversedPath = path.slice();
|
|
||||||
reversedPath.reverse();
|
|
||||||
|
|
||||||
const noteTitle = getNoteTitle(reversedPath);
|
|
||||||
|
|
||||||
console.log(noteTitle);
|
|
||||||
|
|
||||||
results.push({
|
|
||||||
title: noteTitle,
|
|
||||||
path: reversedPath.join('/')
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (noteId === 'root') {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user