diff --git a/src/components/left/main/Chat.tsx b/src/components/left/main/Chat.tsx index bb2ff696e..ec99efb60 100644 --- a/src/components/left/main/Chat.tsx +++ b/src/components/left/main/Chat.tsx @@ -5,7 +5,7 @@ import { withGlobal } from '../../../lib/teact/teactn'; import useLang, { LangFn } from '../../../hooks/useLang'; -import { GlobalActions, MessageListType } from '../../../global/types'; +import { GlobalActions } from '../../../global/types'; import { ApiChat, ApiUser, ApiMessage, ApiMessageOutgoingStatus, ApiFormattedText, MAIN_THREAD_ID, } from '../../../api/types'; @@ -66,16 +66,16 @@ type StateProps = { chat?: ApiChat; isMuted?: boolean; privateChatUser?: ApiUser; - usersById?: Record; actionTargetUserIds?: number[]; + usersById?: Record; actionTargetMessage?: ApiMessage; actionTargetChatId?: number; lastMessageSender?: ApiUser; lastMessageOutgoingStatus?: ApiMessageOutgoingStatus; draft?: ApiFormattedText; - messageListType?: MessageListType; animationLevel?: number; isSelected?: boolean; + canScrollDown?: boolean; lastSyncTime?: number; }; @@ -92,17 +92,17 @@ const Chat: FC = ({ isPinned, chat, isMuted, - usersById, privateChatUser, actionTargetUserIds, + usersById, lastMessageSender, lastMessageOutgoingStatus, actionTargetMessage, actionTargetChatId, draft, - messageListType, animationLevel, isSelected, + canScrollDown, lastSyncTime, openChat, focusLastMessage, @@ -169,12 +169,12 @@ const Chat: FC = ({ const handleClick = useCallback(() => { openChat({ id: chatId, shouldReplaceHistory: true }); - if (isSelected && messageListType === 'thread') { + if (isSelected && canScrollDown) { focusLastMessage(); } }, [ isSelected, - messageListType, + canScrollDown, openChat, chatId, focusLastMessage, @@ -338,6 +338,7 @@ export default memo(withGlobal( threadId: currentThreadId, type: messageListType, } = selectCurrentMessageList(global) || {}; + const isSelected = chatId === currentChatId && currentThreadId === MAIN_THREAD_ID; return { chat, @@ -345,14 +346,14 @@ export default memo(withGlobal( lastMessageSender, ...(isOutgoing && { lastMessageOutgoingStatus: selectOutgoingStatus(global, chat.lastMessage) }), ...(privateChatUserId && { privateChatUser: selectUser(global, privateChatUserId) }), - usersById, actionTargetUserIds, + ...(actionTargetUserIds && { usersById }), actionTargetChatId, actionTargetMessage, draft: selectDraft(global, chatId, MAIN_THREAD_ID), - messageListType, animationLevel: global.settings.byKey.animationLevel, - isSelected: chatId === currentChatId && currentThreadId === MAIN_THREAD_ID, + isSelected, + canScrollDown: isSelected && messageListType === 'thread', lastSyncTime: global.lastSyncTime, }; },