From 82af54555ce24e084b3db7f7834b2366fe258933 Mon Sep 17 00:00:00 2001 From: Alexander Zinchuk Date: Mon, 4 Dec 2023 14:38:20 +0100 Subject: [PATCH] Left Search: Fix search of chats (#3997) --- src/components/left/search/ChatResults.tsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/components/left/search/ChatResults.tsx b/src/components/left/search/ChatResults.tsx index 2b2df7329..820ac1bde 100644 --- a/src/components/left/search/ChatResults.tsx +++ b/src/components/left/search/ChatResults.tsx @@ -7,12 +7,14 @@ import { getActions, getGlobal, withGlobal } from '../../../global'; import type { ApiChat, ApiMessage } from '../../../api/types'; import { LoadMoreDirection } from '../../../types'; +import { ALL_FOLDER_ID } from '../../../config'; import { filterChatsByName, filterUsersByName, sortChatIds, } from '../../../global/helpers'; import { selectTabState } from '../../../global/selectors'; +import { getOrderedIds } from '../../../util/folderManager'; import { unique } from '../../../util/iteratees'; import { MEMO_EMPTY_ARRAY } from '../../../util/memo'; import { throttle } from '../../../util/schedulers'; @@ -131,7 +133,8 @@ const ChatResults: FC = ({ const localContactIds = filterUsersByName( contactIdsWithMe, usersById, searchQuery, currentUserId, lang('SavedMessages'), ); - const localChatIds = filterChatsByName(lang, Object.keys(chatsById), chatsById, searchQuery, currentUserId); + const orderedChatIds = getOrderedIds(ALL_FOLDER_ID) ?? []; + const localChatIds = filterChatsByName(lang, orderedChatIds, chatsById, searchQuery, currentUserId); const localPeerIds = unique([ ...localContactIds,