mirror of
https://github.com/MrUnknownDE/VRCX.git
synced 2026-05-07 14:56:06 +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 match = matchName(ctx.name, query, comparer);
|
||||||
let matchedField = match ? 'name' : null;
|
let matchedField = match ? 'name' : null;
|
||||||
// Include memo and note matching for friends (with raw query for spaces)
|
// 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);
|
match = localeIncludes(ctx.memo, query, comparer);
|
||||||
if (match) matchedField = 'memo';
|
if (match) matchedField = 'memo';
|
||||||
}
|
}
|
||||||
if (!match && ctx.ref.note) {
|
if (!match && ctx.ref.note && query.length >= 2) {
|
||||||
match = localeIncludes(ctx.ref.note, query, comparer);
|
match = localeIncludes(ctx.ref.note, query, comparer);
|
||||||
if (match) matchedField = 'note';
|
if (match) matchedField = 'note';
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ export const useQuickSearchStore = defineStore('QuickSearch', () => {
|
|||||||
indexUpdateTimer = null;
|
indexUpdateTimer = null;
|
||||||
if (!isOpen.value) return;
|
if (!isOpen.value) return;
|
||||||
sendIndexUpdate();
|
sendIndexUpdate();
|
||||||
if (query.value && query.value.length >= 2) {
|
if (query.value && query.value.length >= 1) {
|
||||||
dispatchSearch();
|
dispatchSearch();
|
||||||
}
|
}
|
||||||
}, 200);
|
}, 200);
|
||||||
@@ -106,7 +106,7 @@ export const useQuickSearchStore = defineStore('QuickSearch', () => {
|
|||||||
|
|
||||||
function dispatchSearch() {
|
function dispatchSearch() {
|
||||||
const q = query.value;
|
const q = query.value;
|
||||||
if (!q || q.length < 2) {
|
if (!q || q.length < 1) {
|
||||||
++searchSeq;
|
++searchSeq;
|
||||||
clearResults();
|
clearResults();
|
||||||
return;
|
return;
|
||||||
@@ -126,7 +126,7 @@ export const useQuickSearchStore = defineStore('QuickSearch', () => {
|
|||||||
|
|
||||||
watch(query, dispatchSearch);
|
watch(query, dispatchSearch);
|
||||||
watch(currentUserId, () => {
|
watch(currentUserId, () => {
|
||||||
if (query.value && query.value.length >= 2) {
|
if (query.value && query.value.length >= 1) {
|
||||||
dispatchSearch();
|
dispatchSearch();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -135,7 +135,7 @@ export const useQuickSearchStore = defineStore('QuickSearch', () => {
|
|||||||
if (open) {
|
if (open) {
|
||||||
startIndexWatchers();
|
startIndexWatchers();
|
||||||
sendIndexUpdate();
|
sendIndexUpdate();
|
||||||
if (query.value && query.value.length >= 2) {
|
if (query.value && query.value.length >= 1) {
|
||||||
dispatchSearch();
|
dispatchSearch();
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -176,11 +176,11 @@ function searchFriends(query, cleanQuery, comparer, limit = 10) {
|
|||||||
for (const ctx of indexedFriends) {
|
for (const ctx of indexedFriends) {
|
||||||
let match = matchName(ctx.name, cleanQuery, comparer, ctx._normalized);
|
let match = matchName(ctx.name, cleanQuery, comparer, ctx._normalized);
|
||||||
let matchedField = match ? 'name' : null;
|
let matchedField = match ? 'name' : null;
|
||||||
if (!match && ctx.memo) {
|
if (!match && ctx.memo && query.length >= 2) {
|
||||||
match = localeIncludes(ctx.memo, query, comparer);
|
match = localeIncludes(ctx.memo, query, comparer);
|
||||||
if (match) matchedField = 'memo';
|
if (match) matchedField = 'memo';
|
||||||
}
|
}
|
||||||
if (!match && ctx.note) {
|
if (!match && ctx.note && query.length >= 2) {
|
||||||
match = localeIncludes(ctx.note, query, comparer);
|
match = localeIncludes(ctx.note, query, comparer);
|
||||||
if (match) matchedField = 'note';
|
if (match) matchedField = 'note';
|
||||||
}
|
}
|
||||||
@@ -255,7 +255,7 @@ function searchItems(
|
|||||||
function handleSearch(payload) {
|
function handleSearch(payload) {
|
||||||
const { seq, query, currentUserId, language } = payload;
|
const { seq, query, currentUserId, language } = payload;
|
||||||
|
|
||||||
if (!query || query.length < 2) {
|
if (!query || query.length < 1) {
|
||||||
self.postMessage({
|
self.postMessage({
|
||||||
type: 'searchResult',
|
type: 'searchResult',
|
||||||
payload: {
|
payload: {
|
||||||
|
|||||||
Reference in New Issue
Block a user