From 79e3ae3b6e25c7ad1869c756a20e20c4dac4f127 Mon Sep 17 00:00:00 2001 From: Alexander Zinchuk Date: Fri, 3 Mar 2023 14:30:35 +0100 Subject: [PATCH] Messages List: Fix position for sticky date (#2709) --- src/components/middle/MiddleColumn.tsx | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/components/middle/MiddleColumn.tsx b/src/components/middle/MiddleColumn.tsx index 64773b081..3b4c56ca1 100644 --- a/src/components/middle/MiddleColumn.tsx +++ b/src/components/middle/MiddleColumn.tsx @@ -40,7 +40,9 @@ import { selectIsUserBlocked, selectPinnedIds, selectReplyingToId, - selectTheme, selectThreadInfo, + selectTheme, + selectThreadInfo, + selectChatMessage, } from '../../global/selectors'; import { getCanPostInChat, @@ -98,7 +100,8 @@ type StateProps = { canPost?: boolean; currentUserBannedRights?: ApiChatBannedRights; defaultBannedRights?: ApiChatBannedRights; - hasPinnedOrAudioPlayer?: boolean; + hasPinned?: boolean; + hasAudioPlayer?: boolean; pinnedMessagesCount?: number; theme: ThemeKey; customBackground?: string; @@ -144,7 +147,8 @@ const MiddleColumn: FC = ({ canPost, currentUserBannedRights, defaultBannedRights, - hasPinnedOrAudioPlayer, + hasPinned, + hasAudioPlayer, pinnedMessagesCount, customBackground, theme, @@ -199,7 +203,7 @@ const MiddleColumn: FC = ({ const isMobileSearchActive = isMobile && hasCurrentTextSearch; const closeAnimationDuration = isMobile ? 450 + ANIMATION_END_DELAY : undefined; - const hasTools = hasPinnedOrAudioPlayer && ( + const hasTools = hasPinned && ( windowWidth < MOBILE_SCREEN_MAX_WIDTH || ( isRightColumnShown && windowWidth > MIN_SCREEN_WIDTH_FOR_STATIC_RIGHT_COLUMN @@ -207,6 +211,7 @@ const MiddleColumn: FC = ({ ) || ( windowWidth >= MIN_SCREEN_WIDTH_FOR_STATIC_LEFT_COLUMN && windowWidth < SAFE_SCREEN_WIDTH_FOR_CHAT_INFO + && hasAudioPlayer ) ); @@ -656,6 +661,9 @@ export default memo(withGlobal( const shouldBlockSendInForum = chat?.isForum ? threadId === MAIN_THREAD_ID && !replyingToId && (chat.topics?.[GENERAL_TOPIC_ID]?.isClosed) : false; + const audioMessage = audioChatId && audioMessageId + ? selectChatMessage(global, audioChatId, audioMessageId) + : undefined; return { ...state, @@ -675,11 +683,11 @@ export default memo(withGlobal( isScheduledMessageList, currentUserBannedRights: chat?.currentUserBannedRights, defaultBannedRights: chat?.defaultBannedRights, - hasPinnedOrAudioPlayer: ( + hasPinned: ( (threadId !== MAIN_THREAD_ID && !chat?.isForum) || Boolean(!isPinnedMessageList && pinnedIds?.length) - || Boolean(audioChatId && audioMessageId) ), + hasAudioPlayer: Boolean(audioMessage), pinnedMessagesCount: pinnedIds ? pinnedIds.length : 0, shouldSkipHistoryAnimations, isChannel,