Messages List: Fix position for sticky date (#2709)

This commit is contained in:
Alexander Zinchuk 2023-03-03 14:30:35 +01:00
parent b60d888d00
commit 79e3ae3b6e

View File

@ -40,7 +40,9 @@ import {
selectIsUserBlocked, selectIsUserBlocked,
selectPinnedIds, selectPinnedIds,
selectReplyingToId, selectReplyingToId,
selectTheme, selectThreadInfo, selectTheme,
selectThreadInfo,
selectChatMessage,
} from '../../global/selectors'; } from '../../global/selectors';
import { import {
getCanPostInChat, getCanPostInChat,
@ -98,7 +100,8 @@ type StateProps = {
canPost?: boolean; canPost?: boolean;
currentUserBannedRights?: ApiChatBannedRights; currentUserBannedRights?: ApiChatBannedRights;
defaultBannedRights?: ApiChatBannedRights; defaultBannedRights?: ApiChatBannedRights;
hasPinnedOrAudioPlayer?: boolean; hasPinned?: boolean;
hasAudioPlayer?: boolean;
pinnedMessagesCount?: number; pinnedMessagesCount?: number;
theme: ThemeKey; theme: ThemeKey;
customBackground?: string; customBackground?: string;
@ -144,7 +147,8 @@ const MiddleColumn: FC<OwnProps & StateProps> = ({
canPost, canPost,
currentUserBannedRights, currentUserBannedRights,
defaultBannedRights, defaultBannedRights,
hasPinnedOrAudioPlayer, hasPinned,
hasAudioPlayer,
pinnedMessagesCount, pinnedMessagesCount,
customBackground, customBackground,
theme, theme,
@ -199,7 +203,7 @@ const MiddleColumn: FC<OwnProps & StateProps> = ({
const isMobileSearchActive = isMobile && hasCurrentTextSearch; const isMobileSearchActive = isMobile && hasCurrentTextSearch;
const closeAnimationDuration = isMobile ? 450 + ANIMATION_END_DELAY : undefined; const closeAnimationDuration = isMobile ? 450 + ANIMATION_END_DELAY : undefined;
const hasTools = hasPinnedOrAudioPlayer && ( const hasTools = hasPinned && (
windowWidth < MOBILE_SCREEN_MAX_WIDTH windowWidth < MOBILE_SCREEN_MAX_WIDTH
|| ( || (
isRightColumnShown && windowWidth > MIN_SCREEN_WIDTH_FOR_STATIC_RIGHT_COLUMN isRightColumnShown && windowWidth > MIN_SCREEN_WIDTH_FOR_STATIC_RIGHT_COLUMN
@ -207,6 +211,7 @@ const MiddleColumn: FC<OwnProps & StateProps> = ({
) || ( ) || (
windowWidth >= MIN_SCREEN_WIDTH_FOR_STATIC_LEFT_COLUMN windowWidth >= MIN_SCREEN_WIDTH_FOR_STATIC_LEFT_COLUMN
&& windowWidth < SAFE_SCREEN_WIDTH_FOR_CHAT_INFO && windowWidth < SAFE_SCREEN_WIDTH_FOR_CHAT_INFO
&& hasAudioPlayer
) )
); );
@ -656,6 +661,9 @@ export default memo(withGlobal<OwnProps>(
const shouldBlockSendInForum = chat?.isForum const shouldBlockSendInForum = chat?.isForum
? threadId === MAIN_THREAD_ID && !replyingToId && (chat.topics?.[GENERAL_TOPIC_ID]?.isClosed) ? threadId === MAIN_THREAD_ID && !replyingToId && (chat.topics?.[GENERAL_TOPIC_ID]?.isClosed)
: false; : false;
const audioMessage = audioChatId && audioMessageId
? selectChatMessage(global, audioChatId, audioMessageId)
: undefined;
return { return {
...state, ...state,
@ -675,11 +683,11 @@ export default memo(withGlobal<OwnProps>(
isScheduledMessageList, isScheduledMessageList,
currentUserBannedRights: chat?.currentUserBannedRights, currentUserBannedRights: chat?.currentUserBannedRights,
defaultBannedRights: chat?.defaultBannedRights, defaultBannedRights: chat?.defaultBannedRights,
hasPinnedOrAudioPlayer: ( hasPinned: (
(threadId !== MAIN_THREAD_ID && !chat?.isForum) (threadId !== MAIN_THREAD_ID && !chat?.isForum)
|| Boolean(!isPinnedMessageList && pinnedIds?.length) || Boolean(!isPinnedMessageList && pinnedIds?.length)
|| Boolean(audioChatId && audioMessageId)
), ),
hasAudioPlayer: Boolean(audioMessage),
pinnedMessagesCount: pinnedIds ? pinnedIds.length : 0, pinnedMessagesCount: pinnedIds ? pinnedIds.length : 0,
shouldSkipHistoryAnimations, shouldSkipHistoryAnimations,
isChannel, isChannel,