mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-07-27 18:12:29 +08:00
feat(autocomplete): don't search unless length is 3
This commit is contained in:
parent
766b0723f7
commit
fd53e35f6f
@ -70,9 +70,14 @@ async function autocompleteSource(term: string, cb: (rows: Suggestion[]) => void
|
|||||||
}
|
}
|
||||||
|
|
||||||
const activeNoteId = appContext.tabManager.getActiveContextNoteId();
|
const activeNoteId = appContext.tabManager.getActiveContextNoteId();
|
||||||
|
const length = term.trim().length;
|
||||||
|
|
||||||
let results: Suggestion[] = await server.get<Suggestion[]>(`autocomplete?query=${encodeURIComponent(term)}&activeNoteId=${activeNoteId}&fastSearch=${fastSearch}`);
|
let results: Suggestion[] = [];
|
||||||
if (term.trim().length >= 1 && options.allowCreatingNotes) {
|
if (length >= 3) {
|
||||||
|
results = await server.get<Suggestion[]>(`autocomplete?query=${encodeURIComponent(term)}&activeNoteId=${activeNoteId}&fastSearch=${fastSearch}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (length >= 1 && options.allowCreatingNotes) {
|
||||||
results = [
|
results = [
|
||||||
{
|
{
|
||||||
action: "create-note",
|
action: "create-note",
|
||||||
@ -83,7 +88,7 @@ async function autocompleteSource(term: string, cb: (rows: Suggestion[]) => void
|
|||||||
].concat(results);
|
].concat(results);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (term.trim().length >= 1 && options.allowJumpToSearchNotes) {
|
if (length >= 1 && options.allowJumpToSearchNotes) {
|
||||||
results = results.concat([
|
results = results.concat([
|
||||||
{
|
{
|
||||||
action: "search-notes",
|
action: "search-notes",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user