Context Menu: Refactoring (#5398)

This commit is contained in:
Alexander Zinchuk 2025-01-21 18:19:46 +01:00
parent a473c468c7
commit d9b1923c83
2 changed files with 11 additions and 12 deletions

View File

@ -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<OwnProps & StateProps> = ({
isWithPaidReaction,
onClose,
onCloseAnimationEnd,
contactUserFullName,
userFullName,
canGift,
}) => {
const {
@ -698,7 +698,7 @@ const ContextMenuContainer: FC<OwnProps & StateProps> = ({
onTranslate={handleTranslate}
onShowOriginal={handleShowOriginal}
onSelectLanguage={handleSelectLanguage}
contactUserFullName={contactUserFullName}
userFullName={userFullName}
canGift={canGift}
/>
<PinMessageModal
@ -729,9 +729,8 @@ export default memo(withGlobal<OwnProps>(
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<OwnProps>(
isWithPaidReaction: chatFullInfo?.isPaidReactionAvailable,
poll,
story,
contactUserFullName,
userFullName,
canGift,
};
},

View File

@ -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<OwnProps> = ({
onTranslate,
onShowOriginal,
onSelectLanguage,
contactUserFullName,
userFullName,
canGift,
}) => {
const {
@ -238,10 +238,10 @@ const MessageContextMenu: FC<OwnProps> = ({
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<OwnProps> = ({
&& (
<MenuItem icon="gift" onClick={handleGiftClick}>
{message?.isOutgoing ? lang('SendAnotherGift')
: lang('Conversation.ContextMenuSendGiftTo', contactUserFullName)}
: lang('Conversation.ContextMenuSendGiftTo', userFullName)}
</MenuItem>
)}
{canSendNow && <MenuItem icon="send-outline" onClick={onSend}>{lang('MessageScheduleSend')}</MenuItem>}