From 8bae7c9e825095b11614ff8d643c9c461db0b871 Mon Sep 17 00:00:00 2001 From: Alexander Zinchuk Date: Tue, 8 Feb 2022 22:29:39 +0100 Subject: [PATCH] [Refactoring] Finally get rid of deprecated `openUserInfo` --- src/api/gramjs/methods/messages.ts | 6 +-- src/api/gramjs/methods/users.ts | 2 +- src/components/common/UserLink.tsx | 6 +-- src/components/middle/message/Contact.tsx | 6 +-- .../middle/message/hooks/useInnerHandlers.ts | 19 +++------ src/components/right/Profile.tsx | 18 +++------ src/components/right/RightColumn.tsx | 38 +++++------------- .../right/management/JoinRequest.tsx | 4 +- .../right/management/ManageGroupMembers.tsx | 6 +-- .../right/management/ManageInviteInfo.tsx | 8 ++-- src/global/cache.ts | 3 +- src/global/types.ts | 4 +- src/modules/actions/api/globalSearch.ts | 2 +- src/modules/actions/api/localSearch.ts | 35 ++++++++-------- src/modules/actions/ui/users.ts | 14 +------ src/modules/reducers/users.ts | 14 ------- src/modules/selectors/localSearch.ts | 14 ++----- src/modules/selectors/ui.ts | 40 ++++--------------- src/types/index.ts | 1 - 19 files changed, 74 insertions(+), 166 deletions(-) diff --git a/src/api/gramjs/methods/messages.ts b/src/api/gramjs/methods/messages.ts index d4223d576..27bdb94ae 100644 --- a/src/api/gramjs/methods/messages.ts +++ b/src/api/gramjs/methods/messages.ts @@ -834,9 +834,9 @@ export async function requestThreadInfoUpdate({ } export async function searchMessagesLocal({ - chatOrUser, type, query, topMessageId, minDate, maxDate, ...pagination + chat, type, query, topMessageId, minDate, maxDate, ...pagination }: { - chatOrUser: ApiChat | ApiUser; + chat: ApiChat; type?: ApiMessageSearchType | ApiGlobalMessageSearchType; query?: string; topMessageId?: number; @@ -873,7 +873,7 @@ export async function searchMessagesLocal({ } const result = await invokeRequest(new GramJs.messages.Search({ - peer: buildInputPeer(chatOrUser.id, chatOrUser.accessHash), + peer: buildInputPeer(chat.id, chat.accessHash), filter, q: query || '', topMsgId: topMessageId, diff --git a/src/api/gramjs/methods/users.ts b/src/api/gramjs/methods/users.ts index c2ce78eab..6214a8d17 100644 --- a/src/api/gramjs/methods/users.ts +++ b/src/api/gramjs/methods/users.ts @@ -230,7 +230,7 @@ export async function fetchProfilePhotos(user?: ApiUser, chat?: ApiChat) { } const result = await searchMessagesLocal({ - chatOrUser: chat!, + chat: chat!, type: 'profilePhoto', limit: PROFILE_PHOTOS_LIMIT, }); diff --git a/src/components/common/UserLink.tsx b/src/components/common/UserLink.tsx index 3064bc4ab..4bd3da652 100644 --- a/src/components/common/UserLink.tsx +++ b/src/components/common/UserLink.tsx @@ -16,13 +16,13 @@ type OwnProps = { const UserLink: FC = ({ className, sender, children, }) => { - const { openUserInfo } = getDispatch(); + const { openChat } = getDispatch(); const handleClick = useCallback(() => { if (sender) { - openUserInfo({ id: sender.id }); + openChat({ id: sender.id }); } - }, [sender, openUserInfo]); + }, [sender, openChat]); if (!sender) { return children; diff --git a/src/components/middle/message/Contact.tsx b/src/components/middle/message/Contact.tsx index bfd90102c..496603343 100644 --- a/src/components/middle/message/Contact.tsx +++ b/src/components/middle/message/Contact.tsx @@ -23,7 +23,7 @@ type StateProps = { const Contact: FC = ({ contact, user, phoneCodeList, }) => { - const { openUserInfo } = getDispatch(); + const { openChat } = getDispatch(); const { firstName, @@ -33,8 +33,8 @@ const Contact: FC = ({ } = contact; const handleClick = useCallback(() => { - openUserInfo({ id: userId }); - }, [openUserInfo, userId]); + openChat({ id: userId }); + }, [openChat, userId]); return (
{ if (!senderPeer) { @@ -53,13 +48,11 @@ export default function useInnerHandlers( if (asForwarded && forwardInfo?.channelPostId) { focusMessage({ chatId: senderPeer.id, messageId: forwardInfo.channelPostId }); - } else if (isUserId(senderPeer.id)) { - openUserInfo({ id: senderPeer.id }); } else { openChat({ id: senderPeer.id }); } }, [ - asForwarded, focusMessage, forwardInfo, lang, openChat, openUserInfo, senderPeer, showNotification, + asForwarded, focusMessage, forwardInfo, lang, openChat, senderPeer, showNotification, ]); const handleViaBotClick = useCallback(() => { @@ -67,8 +60,8 @@ export default function useInnerHandlers( return; } - openUserInfo({ id: botSender.id }); - }, [botSender, openUserInfo]); + openChat({ id: botSender.id }); + }, [botSender, openChat]); const handleReplyClick = useCallback((): void => { focusMessage({ diff --git a/src/components/right/Profile.tsx b/src/components/right/Profile.tsx index 546554650..3a7fd7907 100644 --- a/src/components/right/Profile.tsx +++ b/src/components/right/Profile.tsx @@ -65,7 +65,6 @@ import { useIntersectionObserver } from '../../hooks/useIntersectionObserver'; type OwnProps = { chatId: string; - userId?: string; profileState: ProfileState; onProfileStateChange: (state: ProfileState) => void; }; @@ -143,7 +142,6 @@ const Profile: FC = ({ searchMediaMessagesLocal, openMediaViewer, openAudioPlayer, - openUserInfo, focusMessage, loadProfilePhotos, setNewChatMembersDialogState, @@ -222,8 +220,8 @@ const Profile: FC = ({ }, [profileId, openAudioPlayer]); const handleMemberClick = useCallback((id: string) => { - openUserInfo({ id }); - }, [openUserInfo]); + openChat({ id }); + }, [openChat]); const handleMessageFocus = useCallback((messageId: number) => { focusMessage({ chatId: profileId, messageId }); @@ -492,10 +490,9 @@ function buildInfiniteScrollItemSelector(resultType: string) { } export default memo(withGlobal( - (global, { chatId, userId }): StateProps => { + (global, { chatId }): StateProps => { const chat = selectChat(global, chatId); - - const chatMessages = selectChatMessages(global, userId || chatId); + const chatMessages = selectChatMessages(global, chatId); const { currentType: mediaSearchType, resultsByType } = selectCurrentMediaSearch(global) || {}; const { foundIds } = (resultsByType && mediaSearchType && resultsByType[mediaSearchType]) || {}; @@ -509,18 +506,13 @@ export default memo(withGlobal( const areMembersHidden = hasMembersTab && chat && chat.fullInfo && !chat.fullInfo.canViewMembers; const canAddMembers = hasMembersTab && chat && (getHasAdminRight(chat, 'inviteUsers') || chat.isCreator); const canDeleteMembers = hasMembersTab && chat && (getHasAdminRight(chat, 'banUsers') || chat.isCreator); - const activeDownloadIds = selectActiveDownloadIds(global, chatId); let hasCommonChatsTab; let resolvedUserId; let user; - if (userId) { - resolvedUserId = userId; - } else if (isUserId(chatId)) { + if (isUserId(chatId)) { resolvedUserId = chatId; - } - if (resolvedUserId) { user = selectUser(global, resolvedUserId); hasCommonChatsTab = user && !user.isSelf && !isUserBot(user); } diff --git a/src/components/right/RightColumn.tsx b/src/components/right/RightColumn.tsx index 724b0cd96..9a7775b0b 100644 --- a/src/components/right/RightColumn.tsx +++ b/src/components/right/RightColumn.tsx @@ -35,7 +35,6 @@ type StateProps = { contentKey?: RightColumnContent; chatId?: string; threadId?: number; - currentProfileUserId?: string; isChatSelected: boolean; shouldSkipHistoryAnimations?: boolean; nextManagementScreen?: ManagementScreens; @@ -56,7 +55,6 @@ const RightColumn: FC = ({ contentKey, chatId, threadId, - currentProfileUserId, isChatSelected, shouldSkipHistoryAnimations, nextManagementScreen, @@ -64,7 +62,6 @@ const RightColumn: FC = ({ const { toggleChatInfo, toggleManagement, - openUserInfo, closeLocalTextSearch, setStickerSearchQuery, setGifSearchQuery, @@ -84,7 +81,7 @@ const RightColumn: FC = ({ const isScrolledDown = profileState !== ProfileState.Profile; const isOpen = contentKey !== undefined; - const isProfile = contentKey === RightColumnContent.ChatInfo || contentKey === RightColumnContent.UserInfo; + const isProfile = contentKey === RightColumnContent.ChatInfo; const isSearch = contentKey === RightColumnContent.Search; const isManagement = contentKey === RightColumnContent.Management; const isStickerSearch = contentKey === RightColumnContent.StickerSearch; @@ -109,13 +106,6 @@ const RightColumn: FC = ({ } toggleChatInfo(undefined, { forceSyncOnIOs: true }); break; - case RightColumnContent.UserInfo: - if (isScrolledDown && shouldScrollUp) { - setProfileState(ProfileState.Profile); - break; - } - openUserInfo({ id: undefined }, { forceSyncOnIOs: true }); - break; case RightColumnContent.Management: { switch (managementScreen) { case ManagementScreens.Initial: @@ -175,7 +165,7 @@ const RightColumn: FC = ({ break; } }, [ - contentKey, isScrolledDown, toggleChatInfo, openUserInfo, closePollResults, setNewChatMembersDialogState, + contentKey, isScrolledDown, toggleChatInfo, closePollResults, setNewChatMembersDialogState, managementScreen, toggleManagement, closeLocalTextSearch, setStickerSearchQuery, setGifSearchQuery, setEditingExportedInvite, chatId, setOpenedInviteInfo, ]); @@ -213,21 +203,18 @@ const RightColumn: FC = ({ }, [isOverlaying]); // We need to clear profile state and management screen state, when changing chats - useLayoutEffectWithPrevDeps(([prevContentKey, prevChatId]) => { - if ( - (prevContentKey === RightColumnContent.ChatInfo && contentKey === RightColumnContent.UserInfo) - || (prevContentKey === RightColumnContent.UserInfo && contentKey === RightColumnContent.ChatInfo) - || (prevChatId !== chatId) - ) { + useLayoutEffectWithPrevDeps(([prevChatId]) => { + if (prevChatId !== chatId ) { setProfileState(ProfileState.Profile); setManagementScreen(ManagementScreens.Initial); } - }, [contentKey, chatId]); + }, [chatId]); - useHistoryBack(isChatSelected && (contentKey === RightColumnContent.ChatInfo - || contentKey === RightColumnContent.UserInfo || contentKey === RightColumnContent.Management - || contentKey === RightColumnContent.AddingMembers), - () => close(false), toggleChatInfo); + useHistoryBack(isChatSelected && ( + contentKey === RightColumnContent.ChatInfo + || contentKey === RightColumnContent.Management + || contentKey === RightColumnContent.AddingMembers + ), () => close(false), toggleChatInfo); // eslint-disable-next-line consistent-return function renderContent(isActive: boolean) { @@ -247,12 +234,10 @@ const RightColumn: FC = ({ /> ); case RightColumnContent.ChatInfo: - case RightColumnContent.UserInfo: return ( @@ -331,7 +316,6 @@ export default memo(withGlobal( contentKey: selectRightColumnContentKey(global), chatId, threadId, - currentProfileUserId: global.users.selectedId, isChatSelected: Boolean(chatId && areActiveChatsLoaded), shouldSkipHistoryAnimations: global.shouldSkipHistoryAnimations, nextManagementScreen, diff --git a/src/components/right/management/JoinRequest.tsx b/src/components/right/management/JoinRequest.tsx index 92955eabf..a5954333d 100644 --- a/src/components/right/management/JoinRequest.tsx +++ b/src/components/right/management/JoinRequest.tsx @@ -38,7 +38,7 @@ const JoinRequest: FC = ({ serverTimeOffset, chatId, }) => { - const { openUserInfo, hideChatJoinRequest } = getDispatch(); + const { openChat, hideChatJoinRequest } = getDispatch(); const buildClassName = createClassNameBuilder('JoinRequest'); const lang = useLang(); @@ -50,7 +50,7 @@ const JoinRequest: FC = ({ ? formatTime(lang, fixedDate) : formatHumanDate(lang, fixedDate, true, false, true); const handleUserClick = () => { - openUserInfo({ id: userId }); + openChat({ id: userId }); }; const handleAcceptRequest = useCallback(() => { diff --git a/src/components/right/management/ManageGroupMembers.tsx b/src/components/right/management/ManageGroupMembers.tsx index 37ef882f1..682d701c9 100644 --- a/src/components/right/management/ManageGroupMembers.tsx +++ b/src/components/right/management/ManageGroupMembers.tsx @@ -62,7 +62,7 @@ const ManageGroupMembers: FC = ({ onScreenSelect, onChatMemberSelect, }) => { - const { openUserInfo, setUserSearchQuery, loadContactList } = getDispatch(); + const { openChat, setUserSearchQuery, loadContactList } = getDispatch(); const lang = useLang(); // eslint-disable-next-line no-null/no-null const inputRef = useRef(null); @@ -126,9 +126,9 @@ const ManageGroupMembers: FC = ({ onChatMemberSelect!(id, false); onScreenSelect!(ManagementScreens.ChatNewAdminRights); } else { - openUserInfo({ id }); + openChat({ id }); } - }, [noAdmins, onChatMemberSelect, onScreenSelect, openUserInfo]); + }, [noAdmins, onChatMemberSelect, onScreenSelect, openChat]); const handleFilterChange = useCallback((e: React.ChangeEvent) => { setUserSearchQuery({ query: e.target.value }); diff --git a/src/components/right/management/ManageInviteInfo.tsx b/src/components/right/management/ManageInviteInfo.tsx index e0df2fe1f..21311198b 100644 --- a/src/components/right/management/ManageInviteInfo.tsx +++ b/src/components/right/management/ManageInviteInfo.tsx @@ -47,7 +47,7 @@ const ManageInviteInfo: FC = ({ showNotification, loadChatInviteImporters, loadChatInviteRequesters, - openUserInfo, + openChat, } = getDispatch(); const lang = useLang(); @@ -86,7 +86,7 @@ const ManageInviteInfo: FC = ({ {importers.map((importer) => ( openUserInfo({ id: importer.userId })} + onClick={() => openChat({ id: importer.userId })} > = ({ {requesters.map((requester) => ( openUserInfo({ id: requester.userId })} + onClick={() => openChat({ id: requester.userId })} > = ({

{lang('LinkCreatedeBy')}

openUserInfo({ id: adminId })} + onClick={() => openChat({ id: adminId })} > MIN_SCREEN_WIDTH_FOR_STATIC_RIGHT_COLUMN ? selectedId : undefined, }; } diff --git a/src/global/types.ts b/src/global/types.ts index c878c162b..f4aab931c 100644 --- a/src/global/types.ts +++ b/src/global/types.ts @@ -152,8 +152,6 @@ export type GlobalState = { users: { byId: Record; statusesById: Record; - // TODO Remove - selectedId?: string; }; chats: { @@ -563,7 +561,7 @@ export type ActionTypes = ( 'togglePreHistoryHidden' | 'updateChatDefaultBannedRights' | 'updateChatMemberBannedRights' | 'updateChatAdmin' | 'acceptInviteConfirmation' | // users - 'loadFullUser' | 'openUserInfo' | 'loadNearestCountry' | 'loadTopUsers' | 'loadContactList' | + 'loadFullUser' | 'loadNearestCountry' | 'loadTopUsers' | 'loadContactList' | 'loadCurrentUser' | 'updateProfile' | 'checkUsername' | 'addContact' | 'updateContact' | 'deleteContact' | 'loadUser' | 'setUserSearchQuery' | 'loadCommonChats' | // chat creation diff --git a/src/modules/actions/api/globalSearch.ts b/src/modules/actions/api/globalSearch.ts index d0c2ba6f9..931a1e377 100644 --- a/src/modules/actions/api/globalSearch.ts +++ b/src/modules/actions/api/globalSearch.ts @@ -109,7 +109,7 @@ async function searchMessagesGlobal( if (chat) { const localResult = await callApi('searchMessagesLocal', { - chatOrUser: chat, + chat, query, type, limit: GLOBAL_SEARCH_SLICE, diff --git a/src/modules/actions/api/localSearch.ts b/src/modules/actions/api/localSearch.ts index 0039cf744..f7ff973e5 100644 --- a/src/modules/actions/api/localSearch.ts +++ b/src/modules/actions/api/localSearch.ts @@ -2,13 +2,12 @@ import { addReducer, getDispatch, getGlobal, setGlobal, } from '../../../lib/teact/teactn'; -import { ApiChat, ApiUser, MAIN_THREAD_ID } from '../../../api/types'; +import { ApiChat, MAIN_THREAD_ID } from '../../../api/types'; import { MESSAGE_SEARCH_SLICE, SHARED_MEDIA_SLICE } from '../../../config'; import { callApi } from '../../../api/gramjs'; import { selectCurrentTextSearch, - selectCurrentMediaSearchPeerId, selectCurrentMediaSearch, selectCurrentMessageList, selectChat, @@ -45,13 +44,15 @@ addReducer('searchTextMessagesLocal', (global) => { }); addReducer('searchMediaMessagesLocal', (global) => { - const peerId = selectCurrentMediaSearchPeerId(global); - const chatOrUser = peerId - ? global.users.byId[peerId] || global.chats.byId[peerId] - : undefined; + const { chatId } = selectCurrentMessageList(global) || {}; + if (!chatId) { + return; + } + + const chat = selectChat(global, chatId); const currentSearch = selectCurrentMediaSearch(global); - if (!chatOrUser || !currentSearch) { + if (!chat || !currentSearch) { return; } @@ -63,7 +64,7 @@ addReducer('searchMediaMessagesLocal', (global) => { return; } - void searchSharedMedia(chatOrUser, type, offsetId); + void searchSharedMedia(chat, type, offsetId); }); addReducer('searchMessagesByDate', (global, actions, payload) => { @@ -83,7 +84,7 @@ addReducer('searchMessagesByDate', (global, actions, payload) => { }); async function searchTextMessages( - chatOrUser: ApiChat, + chat: ApiChat, threadId: number, topMessageId?: number, query?: string, @@ -94,7 +95,7 @@ async function searchTextMessages( } const result = await callApi('searchMessagesLocal', { - chatOrUser, + chat, type: 'text', query, topMessageId, @@ -122,19 +123,19 @@ async function searchTextMessages( global = addChats(global, buildCollectionByKey(chats, 'id')); global = addUsers(global, buildCollectionByKey(users, 'id')); - global = addChatMessagesById(global, chatOrUser.id, byId); - global = updateLocalTextSearchResults(global, chatOrUser.id, threadId, newFoundIds, totalCount, nextOffsetId); + global = addChatMessagesById(global, chat.id, byId); + global = updateLocalTextSearchResults(global, chat.id, threadId, newFoundIds, totalCount, nextOffsetId); setGlobal(global); } async function searchSharedMedia( - chatOrUser: ApiChat | ApiUser, + chat: ApiChat, type: SharedMediaType, offsetId?: number, isBudgetPreload = false, ) { const result = await callApi('searchMessagesLocal', { - chatOrUser, + chat, type, limit: SHARED_MEDIA_SLICE * 2, offsetId, @@ -160,12 +161,12 @@ async function searchSharedMedia( global = addChats(global, buildCollectionByKey(chats, 'id')); global = addUsers(global, buildCollectionByKey(users, 'id')); - global = addChatMessagesById(global, chatOrUser.id, byId); - global = updateLocalMediaSearchResults(global, chatOrUser.id, type, newFoundIds, totalCount, nextOffsetId); + global = addChatMessagesById(global, chat.id, byId); + global = updateLocalMediaSearchResults(global, chat.id, type, newFoundIds, totalCount, nextOffsetId); setGlobal(global); if (!isBudgetPreload) { - searchSharedMedia(chatOrUser, type, nextOffsetId, true); + searchSharedMedia(chat, type, nextOffsetId, true); } } diff --git a/src/modules/actions/ui/users.ts b/src/modules/actions/ui/users.ts index 0ff923b83..2895dca42 100644 --- a/src/modules/actions/ui/users.ts +++ b/src/modules/actions/ui/users.ts @@ -1,18 +1,6 @@ import { addReducer } from '../../../lib/teact/teactn'; -import { GlobalState } from '../../../global/types'; - -import { updateSelectedUserId, updateUserSearch } from '../../reducers'; - -addReducer('openUserInfo', (global, actions, payload) => { - const { id } = payload!; - - actions.openChat({ id }); -}); - -const clearSelectedUserId = (global: GlobalState) => updateSelectedUserId(global, undefined); - -addReducer('openChat', clearSelectedUserId); +import { updateUserSearch } from '../../reducers'; addReducer('setUserSearchQuery', (global, actions, payload) => { const { query } = payload!; diff --git a/src/modules/reducers/users.ts b/src/modules/reducers/users.ts index 1fd08af46..08c2e1a66 100644 --- a/src/modules/reducers/users.ts +++ b/src/modules/reducers/users.ts @@ -122,20 +122,6 @@ function getUpdatedUser(global: GlobalState, userId: string, userUpdate: Partial return updatedUser; } -export function updateSelectedUserId(global: GlobalState, selectedId?: string): GlobalState { - if (global.users.selectedId === selectedId) { - return global; - } - - return { - ...global, - users: { - ...global.users, - selectedId, - }, - }; -} - export function deleteContact(global: GlobalState, userId: string): GlobalState { const { byId } = global.users; const { userIds } = global.contactList || {}; diff --git a/src/modules/selectors/localSearch.ts b/src/modules/selectors/localSearch.ts index 9238b718d..9a98106a0 100644 --- a/src/modules/selectors/localSearch.ts +++ b/src/modules/selectors/localSearch.ts @@ -17,19 +17,11 @@ export function selectCurrentTextSearch(global: GlobalState) { return currentSearch; } -export function selectCurrentMediaSearchPeerId(global: GlobalState) { - const { byChatId } = global.localMediaSearch; - const { chatId } = selectCurrentMessageList(global) || {}; - const currentProfileUserId = global.users.selectedId; - - return currentProfileUserId && byChatId[currentProfileUserId] ? currentProfileUserId : chatId; -} - export function selectCurrentMediaSearch(global: GlobalState) { - const peerId = selectCurrentMediaSearchPeerId(global); - if (!peerId) { + const { chatId } = selectCurrentMessageList(global) || {}; + if (!chatId) { return undefined; } - return global.localMediaSearch.byChatId[peerId]; + return global.localMediaSearch.byChatId[chatId]; } diff --git a/src/modules/selectors/ui.ts b/src/modules/selectors/ui.ts index 641995239..54e3b1b4e 100644 --- a/src/modules/selectors/ui.ts +++ b/src/modules/selectors/ui.ts @@ -4,8 +4,7 @@ import { NewChatMembersProgress, RightColumnContent } from '../../types'; import { getSystemTheme, IS_SINGLE_COLUMN_LAYOUT } from '../../util/environment'; import { selectCurrentMessageList, selectIsPollResultsOpen } from './messages'; import { selectCurrentTextSearch } from './localSearch'; -import { selectCurrentStickerSearch, selectCurrentGifSearch } from './symbols'; -import { selectAreActiveChatsLoaded } from './chats'; +import { selectCurrentGifSearch, selectCurrentStickerSearch } from './symbols'; import { selectCurrentManagement } from './management'; export function selectIsMediaViewerOpen(global: GlobalState) { @@ -14,42 +13,19 @@ export function selectIsMediaViewerOpen(global: GlobalState) { } export function selectRightColumnContentKey(global: GlobalState) { - const { - users, - isChatInfoShown, - newChatMembersProgress, - } = global; - - const isAddingChatMembersShown = newChatMembersProgress !== NewChatMembersProgress.Closed; - const isPollResults = selectIsPollResultsOpen(global); - const isSearch = Boolean(!IS_SINGLE_COLUMN_LAYOUT && selectCurrentTextSearch(global)); - const isManagement = selectCurrentManagement(global); - const stickerSearch = selectCurrentStickerSearch(global); - const isStickerSearch = stickerSearch.query !== undefined; - const gifSearch = selectCurrentGifSearch(global); - const isGifSearch = gifSearch.query !== undefined; - const { chatId: currentChatId } = selectCurrentMessageList(global) || {}; - const currentProfileUserId = users.selectedId; - const areActiveChatsLoaded = selectAreActiveChatsLoaded(global); - const isUserInfo = Boolean(currentProfileUserId && areActiveChatsLoaded); - const isChatShown = Boolean(currentChatId && areActiveChatsLoaded); - const isChatInfo = isChatShown && isChatInfoShown; - - return isPollResults ? ( + return selectIsPollResultsOpen(global) ? ( RightColumnContent.PollResults - ) : isSearch ? ( + ) : !IS_SINGLE_COLUMN_LAYOUT && selectCurrentTextSearch(global) ? ( RightColumnContent.Search - ) : isManagement ? ( + ) : selectCurrentManagement(global) ? ( RightColumnContent.Management - ) : isStickerSearch ? ( + ) : selectCurrentStickerSearch(global).query !== undefined ? ( RightColumnContent.StickerSearch - ) : isGifSearch ? ( + ) : selectCurrentGifSearch(global).query !== undefined ? ( RightColumnContent.GifSearch - ) : isAddingChatMembersShown ? ( + ) : global.newChatMembersProgress !== NewChatMembersProgress.Closed ? ( RightColumnContent.AddingMembers - ) : isUserInfo ? ( - RightColumnContent.UserInfo - ) : isChatInfo ? ( + ) : global.isChatInfoShown && selectCurrentMessageList(global) ? ( RightColumnContent.ChatInfo ) : undefined; } diff --git a/src/types/index.ts b/src/types/index.ts index 30be1a461..574322a01 100644 --- a/src/types/index.ts +++ b/src/types/index.ts @@ -234,7 +234,6 @@ export enum GlobalSearchContent { export enum RightColumnContent { ChatInfo, - UserInfo, Search, Management, StickerSearch,