From 71059dff066f1c0c442ba9524d91008393c9e3c4 Mon Sep 17 00:00:00 2001 From: Alexander Zinchuk Date: Fri, 21 Jan 2022 17:29:19 +0100 Subject: [PATCH] Global Search: Fix missing Saved Messages in search results --- src/components/left/search/ChatResults.tsx | 6 ++++-- src/modules/helpers/users.ts | 10 ++++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/components/left/search/ChatResults.tsx b/src/components/left/search/ChatResults.tsx index 021ef032d..fe6f0b4a8 100644 --- a/src/components/left/search/ChatResults.tsx +++ b/src/components/left/search/ChatResults.tsx @@ -105,7 +105,9 @@ const ChatResults: FC = ({ ]; // No need for expensive global updates on users, so we avoid them const usersById = getGlobal().users.byId; - const foundContactIds = filterUsersByName(contactIdsWithMe, usersById, searchQuery); + const foundContactIds = filterUsersByName( + contactIdsWithMe, usersById, searchQuery, currentUserId, lang('SavedMessages'), + ); return [ ...sortChatIds(unique([ @@ -114,7 +116,7 @@ const ChatResults: FC = ({ ...(localUserIds || []), ]), chatsById, undefined, currentUserId ? [currentUserId] : undefined), ]; - }, [searchQuery, localContactIds, currentUserId, localChatIds, localUserIds, chatsById]); + }, [searchQuery, currentUserId, localContactIds, lang, localChatIds, localUserIds, chatsById]); const globalResults = useMemo(() => { if (!searchQuery || searchQuery.length < MIN_QUERY_LENGTH_FOR_GLOBAL_SEARCH || !globalChatIds || !globalUserIds) { diff --git a/src/modules/helpers/users.ts b/src/modules/helpers/users.ts index 6c26cf698..5d1eb553a 100644 --- a/src/modules/helpers/users.ts +++ b/src/modules/helpers/users.ts @@ -232,7 +232,13 @@ export function sortUserIds( }, 'desc'); } -export function filterUsersByName(userIds: string[], usersById: Record, query?: string) { +export function filterUsersByName( + userIds: string[], + usersById: Record, + query?: string, + currentUserId?: string, + savedMessagesLang?: string, +) { if (!query) { return userIds; } @@ -245,7 +251,7 @@ export function filterUsersByName(userIds: string[], usersById: Record