mirror of
https://github.com/vrcx-team/VRCX.git
synced 2026-04-06 00:32:02 +02:00
improve quick search names responsiveness by allowing single character queries
This commit is contained in:
@@ -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';
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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: {
|
||||
|
||||
Reference in New Issue
Block a user