From 92ae1c553161b1bf16e863b7b5122538633c0c62 Mon Sep 17 00:00:00 2001 From: pa Date: Tue, 31 Mar 2026 19:52:04 +0900 Subject: [PATCH] improve quick search names responsiveness by allowing single character queries --- src/shared/utils/quickSearchUtils.js | 4 ++-- src/stores/quickSearch.js | 8 ++++---- src/stores/quickSearchWorker.js | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/shared/utils/quickSearchUtils.js b/src/shared/utils/quickSearchUtils.js index 4853834d..82675051 100644 --- a/src/shared/utils/quickSearchUtils.js +++ b/src/shared/utils/quickSearchUtils.js @@ -67,11 +67,11 @@ export function searchFriends(query, friends, comparer, limit = 10) { let match = matchName(ctx.name, query, comparer); let matchedField = match ? 'name' : null; // Include memo and note matching for friends (with raw query for spaces) - if (!match && ctx.memo) { + if (!match && ctx.memo && query.length >= 2) { match = localeIncludes(ctx.memo, query, comparer); if (match) matchedField = 'memo'; } - if (!match && ctx.ref.note) { + if (!match && ctx.ref.note && query.length >= 2) { match = localeIncludes(ctx.ref.note, query, comparer); if (match) matchedField = 'note'; } diff --git a/src/stores/quickSearch.js b/src/stores/quickSearch.js index 149c7204..c78f7e6f 100644 --- a/src/stores/quickSearch.js +++ b/src/stores/quickSearch.js @@ -67,7 +67,7 @@ export const useQuickSearchStore = defineStore('QuickSearch', () => { indexUpdateTimer = null; if (!isOpen.value) return; sendIndexUpdate(); - if (query.value && query.value.length >= 2) { + if (query.value && query.value.length >= 1) { dispatchSearch(); } }, 200); @@ -106,7 +106,7 @@ export const useQuickSearchStore = defineStore('QuickSearch', () => { function dispatchSearch() { const q = query.value; - if (!q || q.length < 2) { + if (!q || q.length < 1) { ++searchSeq; clearResults(); return; @@ -126,7 +126,7 @@ export const useQuickSearchStore = defineStore('QuickSearch', () => { watch(query, dispatchSearch); watch(currentUserId, () => { - if (query.value && query.value.length >= 2) { + if (query.value && query.value.length >= 1) { dispatchSearch(); } }); @@ -135,7 +135,7 @@ export const useQuickSearchStore = defineStore('QuickSearch', () => { if (open) { startIndexWatchers(); sendIndexUpdate(); - if (query.value && query.value.length >= 2) { + if (query.value && query.value.length >= 1) { dispatchSearch(); } return; diff --git a/src/stores/quickSearchWorker.js b/src/stores/quickSearchWorker.js index 57bb0bbe..da7ae628 100644 --- a/src/stores/quickSearchWorker.js +++ b/src/stores/quickSearchWorker.js @@ -176,11 +176,11 @@ function searchFriends(query, cleanQuery, comparer, limit = 10) { for (const ctx of indexedFriends) { let match = matchName(ctx.name, cleanQuery, comparer, ctx._normalized); let matchedField = match ? 'name' : null; - if (!match && ctx.memo) { + if (!match && ctx.memo && query.length >= 2) { match = localeIncludes(ctx.memo, query, comparer); if (match) matchedField = 'memo'; } - if (!match && ctx.note) { + if (!match && ctx.note && query.length >= 2) { match = localeIncludes(ctx.note, query, comparer); if (match) matchedField = 'note'; } @@ -255,7 +255,7 @@ function searchItems( function handleSearch(payload) { const { seq, query, currentUserId, language } = payload; - if (!query || query.length < 2) { + if (!query || query.length < 1) { self.postMessage({ type: 'searchResult', payload: {