diff --git a/src/api/gramjs/methods/chats.ts b/src/api/gramjs/methods/chats.ts index 7e9d0f323..ec7cdaacc 100644 --- a/src/api/gramjs/methods/chats.ts +++ b/src/api/gramjs/methods/chats.ts @@ -249,17 +249,17 @@ export async function searchChats({ query }: { query: string }) { updateLocalDb(result); - const localPeerIds = result.myResults.map(getApiChatIdFromMtpPeer); + const accountPeerIds = result.myResults.map(getApiChatIdFromMtpPeer); const allChats = result.chats.concat(result.users) .map((user) => buildApiChatFromPreview(user)) .filter(Boolean); const allUsers = result.users.map(buildApiUser).filter((user) => Boolean(user) && !user.isSelf) as ApiUser[]; return { - localChats: allChats.filter((r) => localPeerIds.includes(r.id)), - localUsers: allUsers.filter((u) => localPeerIds.includes(u.id)), - globalChats: allChats.filter((r) => !localPeerIds.includes(r.id)), - globalUsers: allUsers.filter((u) => !localPeerIds.includes(u.id)), + accountChats: allChats.filter((r) => accountPeerIds.includes(r.id)), + accountUsers: allUsers.filter((u) => accountPeerIds.includes(u.id)), + globalChats: allChats.filter((r) => !accountPeerIds.includes(r.id)), + globalUsers: allUsers.filter((u) => !accountPeerIds.includes(u.id)), }; } diff --git a/src/components/left/search/ChatResults.tsx b/src/components/left/search/ChatResults.tsx index 421968903..f143bc8d9 100644 --- a/src/components/left/search/ChatResults.tsx +++ b/src/components/left/search/ChatResults.tsx @@ -41,8 +41,8 @@ export type OwnProps = { type StateProps = { currentUserId?: string; localContactIds?: string[]; - localChatIds?: string[]; - localUserIds?: string[]; + accountChatIds?: string[]; + accountUserIds?: string[]; globalChatIds?: string[]; globalUserIds?: string[]; foundIds?: string[]; @@ -62,8 +62,8 @@ const ChatResults: FC = ({ dateSearchQuery, currentUserId, localContactIds, - localChatIds, - localUserIds, + accountChatIds, + accountUserIds, globalChatIds, globalUserIds, foundIds, @@ -127,18 +127,18 @@ const ChatResults: FC = ({ ]; // No need for expensive global updates on users, so we avoid them const usersById = getGlobal().users.byId; - const foundContactIds = filterUsersByName( + const foundLocalContactIds = filterUsersByName( contactIdsWithMe, usersById, searchQuery, currentUserId, lang('SavedMessages'), ); return [ ...sortChatIds(unique([ - ...(foundContactIds || []), - ...(localChatIds || []), - ...(localUserIds || []), + ...(foundLocalContactIds || []), + ...(accountChatIds || []), + ...(accountUserIds || []), ]), chatsById, undefined, currentUserId ? [currentUserId] : undefined), ]; - }, [searchQuery, currentUserId, localContactIds, lang, localChatIds, localUserIds, chatsById]); + }, [searchQuery, currentUserId, localContactIds, lang, accountChatIds, accountUserIds, chatsById]); useHorizontalScroll(chatSelectionRef, !localResults.length, true); @@ -317,15 +317,15 @@ export default memo(withGlobal( fetchingStatus, globalResults, localResults, resultsByType, } = selectTabState(global).globalSearch; const { chatIds: globalChatIds, userIds: globalUserIds } = globalResults || {}; - const { chatIds: localChatIds, userIds: localUserIds } = localResults || {}; + const { chatIds: accountChatIds, userIds: accountUserIds } = localResults || {}; const { byChatId: globalMessagesByChatId } = messages; const foundIds = resultsByType?.text?.foundIds; return { currentUserId, localContactIds, - localChatIds, - localUserIds, + accountChatIds, + accountUserIds, globalChatIds, globalUserIds, foundIds, diff --git a/src/global/actions/api/globalSearch.ts b/src/global/actions/api/globalSearch.ts index feeafaa4d..76113682b 100644 --- a/src/global/actions/api/globalSearch.ts +++ b/src/global/actions/api/globalSearch.ts @@ -40,22 +40,22 @@ addActionHandler('setGlobalSearchQuery', (global, actions, payload): ActionRetur } const { - localChats, localUsers, globalChats, globalUsers, + accountChats, accountUsers, globalChats, globalUsers, } = result; - if (localChats.length || globalChats.length) { - global = addChats(global, buildCollectionByKey([...localChats, ...globalChats], 'id')); + if (accountChats.length || globalChats.length) { + global = addChats(global, buildCollectionByKey([...accountChats, ...globalChats], 'id')); } - if (localUsers.length || globalUsers.length) { - global = addUsers(global, buildCollectionByKey([...localUsers, ...globalUsers], 'id')); + if (accountUsers.length || globalUsers.length) { + global = addUsers(global, buildCollectionByKey([...accountUsers, ...globalUsers], 'id')); } global = updateGlobalSearchFetchingStatus(global, { chats: false }, tabId); global = updateGlobalSearch(global, { localResults: { - chatIds: localChats.map(({ id }) => id), - userIds: localUsers.map(({ id }) => id), + chatIds: accountChats.map(({ id }) => id), + userIds: accountChats.map(({ id }) => id), }, globalResults: { ...selectTabState(global, tabId).globalSearch.globalResults, diff --git a/src/global/actions/api/users.ts b/src/global/actions/api/users.ts index 23d45fb15..bdae44047 100644 --- a/src/global/actions/api/users.ts +++ b/src/global/actions/api/users.ts @@ -314,13 +314,13 @@ addActionHandler('setUserSearchQuery', (global, actions, payload): ActionReturnT return; } - const { localUsers, globalUsers } = result; + const { accountUsers, globalUsers } = result; let localUserIds; let globalUserIds; - if (localUsers.length) { - global = addUsers(global, buildCollectionByKey(localUsers, 'id')); - localUserIds = localUsers.map(({ id }) => id); + if (accountUsers.length) { + global = addUsers(global, buildCollectionByKey(accountUsers, 'id')); + localUserIds = accountUsers.map(({ id }) => id); } if (globalUsers.length) { global = addUsers(global, buildCollectionByKey(globalUsers, 'id'));