From d9b1923c83271389fe2fa35767add73526764b23 Mon Sep 17 00:00:00 2001 From: Alexander Zinchuk Date: Tue, 21 Jan 2025 18:19:46 +0100 Subject: [PATCH] Context Menu: Refactoring (#5398) --- .../middle/message/ContextMenuContainer.tsx | 13 ++++++------- .../middle/message/MessageContextMenu.tsx | 10 +++++----- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/src/components/middle/message/ContextMenuContainer.tsx b/src/components/middle/message/ContextMenuContainer.tsx index 7d35ea2d1..045668cee 100644 --- a/src/components/middle/message/ContextMenuContainer.tsx +++ b/src/components/middle/message/ContextMenuContainer.tsx @@ -153,7 +153,7 @@ type StateProps = { isChannel?: boolean; canReplyInChat?: boolean; isWithPaidReaction?: boolean; - contactUserFullName?: string; + userFullName?: string; canGift?: boolean; }; @@ -220,7 +220,7 @@ const ContextMenuContainer: FC = ({ isWithPaidReaction, onClose, onCloseAnimationEnd, - contactUserFullName, + userFullName, canGift, }) => { const { @@ -698,7 +698,7 @@ const ContextMenuContainer: FC = ({ onTranslate={handleTranslate} onShowOriginal={handleShowOriginal} onSelectLanguage={handleSelectLanguage} - contactUserFullName={contactUserFullName} + userFullName={userFullName} canGift={canGift} /> ( const chat = selectChat(global, message.chatId); const isPrivate = chat && isUserId(chat.id); const chatFullInfo = !isPrivate ? selectChatFullInfo(global, message.chatId) : undefined; - const contactUserFullName = chat && isUserId(chat.id) - ? getUserFullName(selectUser(global, getPrivateChatUserId(chat)!)) - : undefined; + const user = selectUser(global, message.chatId); + const userFullName = user && getUserFullName(user); const { seenByExpiresAt, seenByMaxChatMembers, maxUniqueReactions, readDateExpiresAt, @@ -883,7 +882,7 @@ export default memo(withGlobal( isWithPaidReaction: chatFullInfo?.isPaidReactionAvailable, poll, story, - contactUserFullName, + userFullName, canGift, }; }, diff --git a/src/components/middle/message/MessageContextMenu.tsx b/src/components/middle/message/MessageContextMenu.tsx index 4684ff0d6..c9dd67ca9 100644 --- a/src/components/middle/message/MessageContextMenu.tsx +++ b/src/components/middle/message/MessageContextMenu.tsx @@ -129,7 +129,7 @@ type OwnProps = { onSendPaidReaction?: NoneToVoidFunction; onShowPaidReactionModal?: NoneToVoidFunction; onReactionPickerOpen?: (position: IAnchorPosition) => void; - contactUserFullName?: string; + userFullName?: string; canGift?: boolean; }; @@ -220,7 +220,7 @@ const MessageContextMenu: FC = ({ onTranslate, onShowOriginal, onSelectLanguage, - contactUserFullName, + userFullName, canGift, }) => { const { @@ -238,10 +238,10 @@ const MessageContextMenu: FC = ({ const seenByDates = message.seenByDates; const isPremiumGift = message.content.action?.type === 'giftPremium'; const isGiftCode = message.content.action?.type === 'giftCode'; - const isStarsGift = message.content.action?.type === 'giftStars'; const isStarGift = message.content.action?.type === 'starGift'; + const isStarGiftUnique = message.content.action?.type === 'starGiftUnique'; const shouldShowGiftButton = isUserId(message.chatId) - && canGift && (isPremiumGift || isGiftCode || isStarsGift || isStarGift); + && canGift && (isPremiumGift || isGiftCode || isStarGift || isStarGiftUnique); const [areItemsHidden, hideItems] = useFlag(); const [isReady, markIsReady, unmarkIsReady] = useFlag(); @@ -403,7 +403,7 @@ const MessageContextMenu: FC = ({ && ( {message?.isOutgoing ? lang('SendAnotherGift') - : lang('Conversation.ContextMenuSendGiftTo', contactUserFullName)} + : lang('Conversation.ContextMenuSendGiftTo', userFullName)} )} {canSendNow && {lang('MessageScheduleSend')}}