Skip to content

Commit

Permalink
Merge pull request #180 from ulu-telegram/master
Browse files Browse the repository at this point in the history
fix
  • Loading branch information
ulugmer authored Dec 4, 2023
2 parents 6523ed4 + efffe04 commit b44d6e7
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions src/components/left/search/CommanMenuChatSearch.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -117,30 +117,32 @@ const CommanMenuChatSearch: React.FC<{
priorityIds = unique([currentUserId, ...priorityIds]);
}

// Фильтрация ID для чатов и пользователей
const chatIds = Object.keys(chatsById).filter((id) => {
const chat = chatsById[id];
if (!chat || priorityIds.includes(id)) return false;
const title = getChatTitle(lang, chat) || '';
return title.toLowerCase().includes(convertedSearchQuery);
return title.toLowerCase().includes(searchQuery.toLowerCase())
|| title.toLowerCase().includes(convertedSearchQuery);
});

const userIds = Object.keys(usersById).filter((id) => {
const user = usersById[id];
if (!user || isDeletedUser(user) || priorityIds.includes(id)) return false;
if (!user || isDeletedUser(user)) return false;
const name = getUserFullName(user) || '';
return name.toLowerCase().includes(convertedSearchQuery);
});

// Сортировка оставшихся чатов
const sortedChatIds = sortChatIds([...chatIds, ...userIds], chatsById);
const allIds = unique([...chatIds, ...userIds]);
const sortedIds = sortChatIds(allIds, chatsById);

// Удаление приоритетных ID из отсортированных ID
const finalIds = sortedIds.filter((id) => !priorityIds.includes(id));

if (searchQuery.length < 2) {
return [];
}

// Объединение приоритетных и отсортированных остальных чатов
return unique([...priorityIds, ...sortedChatIds]);
return unique([...priorityIds, ...finalIds]);
}, [searchQuery, chatsById, usersById, pinnedIds, recentlyFoundChatIds, topUserIds, currentUserId, lang]);

if (!searchQuery) {
Expand Down

0 comments on commit b44d6e7

Please sign in to comment.