Поиск людей: по началу слова, а не по подстроке

«анна» находила и «Жанну» (подстрока), из-за чего нужный человек терялся среди чужих
совпадений. Теперь в поиске по своим связям (карта и список «Связей», поиск по чатам,
«Новый чат», списки друзей в профиле) совпадение – с началом любого слова имени, фамилии
или логина: «анна» → Анна Гусева и anna_guseva, «гус ан» → тоже она, «q_tester» →
q_tester1. Регистр и «ё» не важны. Поиск по всей сети (на сервере) не менялся.
Общая функция – services/people-search.js.
This commit is contained in:
q
2026-10-13 08:59:29 +03:00
parent 6997bc7600
commit af5b26c934
7 changed files with 32 additions and 9 deletions
+2 -1
View File
@@ -8,6 +8,7 @@ import { createLoadingState, createStateMessage } from '../components/feedback.j
import { authService, normalizeDmChatId } from '../state.js';
import { makeProfileRoute } from '../services/shine-routes.js';
import { toUserMessage } from '../services/ui-error-texts.js';
import { matchesPeopleQuery } from '../services/people-search.js';
export const pageMeta = { id: 'contact-search-view', title: 'Новый чат' };
@@ -70,7 +71,7 @@ export function render({ navigate, chrome }) {
results.replaceChildren();
const frag = document.createDocumentFragment();
const ownMatches = mine.filter((person) => !query
|| searchText(`${displayName(person)} ${person.login}`).includes(query));
|| matchesPeopleQuery(`${displayName(person)} ${person.login} ${person.firstName} ${person.lastName}`, query));
const ownShown = query ? ownMatches : ownMatches.filter((person) => person.relationFlag !== 'contact');
if (ownShown.length) {
frag.append(createListSection(query ? `Ваши связи · ${ownShown.length}` : 'Близкие и друзья'));