diff --git a/src/assets/localization/fallback.strings b/src/assets/localization/fallback.strings index 1ea96ca99..c5e8eda53 100644 --- a/src/assets/localization/fallback.strings +++ b/src/assets/localization/fallback.strings @@ -1779,6 +1779,7 @@ "ActionBotAllowedFromApp" = "You allowed this bot to message you when you opened {app}."; "ActionBotAppPlaceholder" = "App"; "ActionGiftTextUnknown" = "You've received a gift"; +"ActionGiftTextUnknownYou" = "You sent a gift"; "ActionGiftTextCost" = "{from} sent you a gift for {cost}"; "ActionGiftTextCostYou" = "You've sent a gift for {cost}"; "ActionGiftTextCostAnonymous" = "Someone sent you a gift for {cost}"; @@ -1868,6 +1869,10 @@ "ActionGiftCodePremiumText_other" = "You've received a gift from {channel}.\n\nYour gift is a **Telegram Premium** subscription for {months} months."; "ActionGiveawayResultStarsText_one" = "You won a prize in a giveaway organized by {channel}.\n\nYour prize is **{amount}** Star."; "ActionGiveawayResultStarsText_other" = "You won a prize in a giveaway organized by {channel}.\n\nYour prize is **{amount}** Stars."; +"ActionGiftCodeSubscriptionText_one" = "You've received a gift from {peer}.\n\nYour gift is a Telegram Premium subscription for {months} month."; +"ActionGiftCodeSubscriptionText_other" = "You've received a gift from {peer}.\n\nYour gift is a Telegram Premium subscription for {months} months."; +"ActionGiftCodeSubscriptionTextYou_one" = "You've sent a gift to {peer}.\n\nTelegram Premium subscription giftcode for {months} month."; +"ActionGiftCodeSubscriptionTextYou_other" = "You've sent a gift to {peer}.\n\nTelegram Premium subscription giftcode for {months} months."; "ActionGiftPremiumTitle_one" = "{months} Month Premium"; "ActionGiftPremiumTitle_other" = "{months} Months Premium"; "ActionGiftPremiumText" = "Subscription for exclusive Telegram features."; @@ -1996,7 +2001,6 @@ "GiftSortByPrice" = "Sort by Price"; "GiftSortByNumber" = "Sort by Number"; "ContextMenuItemSelectAll" = "Select All"; -"ButtonSort" = "Sort"; "GiftAttributeModelPlural_one" = "{count} Model"; "GiftAttributeModelPlural_other" = "{count} Models"; "GiftAttributeBackdropPlural_one" = "{count} Backdrop"; diff --git a/src/components/middle/message/ActionMessage.tsx b/src/components/middle/message/ActionMessage.tsx index 98afbb06a..706006062 100644 --- a/src/components/middle/message/ActionMessage.tsx +++ b/src/components/middle/message/ActionMessage.tsx @@ -49,7 +49,7 @@ import useFocusMessage from './hooks/useFocusMessage'; import ActionMessageText from './ActionMessageText'; import ChannelPhoto from './actions/ChannelPhoto'; import Gift from './actions/Gift'; -import PremiumGiftCode from './actions/GiveawayPrize'; +import GiveawayPrize from './actions/GiveawayPrize'; import StarGift from './actions/StarGift'; import StarGiftUnique from './actions/StarGiftUnique'; import SuggestedPhoto from './actions/SuggestedPhoto'; @@ -336,8 +336,9 @@ const ActionMessage = ({ case 'prizeStars': case 'giftCode': return ( - { + const peer = channel || sender; + const peerTitle = peer && getPeerTitle(lang, peer); + const peerFallbackText = lang('ActionFallbackChat'); + + return renderPeerLink(peer?.id, peerTitle || peerFallbackText); + }, [channel, sender, lang]); + return (
-

{lang('ActionGiveawayResultTitle')}

+

+ {lang(action.type !== 'giftCode' || action.isViaGiveaway + ? 'ActionGiveawayResultTitle' : 'GiftInfoTitle')} +

{action.type === 'giftCode' && ( - lang( - action.isViaGiveaway ? 'ActionGiveawayResultPremiumText' : 'ActionGiftCodePremiumText', - { months: action.months, channel: channelLink }, + action.isViaGiveaway ? lang( + 'ActionGiveawayResultPremiumText', + { channel: channelLink, months: action.months }, { withNodes: true, withMarkdown: true, pluralValue: action.months, renderTextFilters: ['br'], - }, - ) + }) + : translateWithYou( + lang, + 'ActionGiftCodeSubscriptionText', + sender?.id === currentUserId, + { peer: peerLink, months: action.months }, + { + pluralValue: action.months, + renderTextFilters: ['br'], + }) )} {action.type === 'prizeStars' && ( lang( @@ -112,14 +135,16 @@ const GiveawayPrizeAction = ({ export default memo(withGlobal( (global, { action }): StateProps => { + const currentUserId = global.currentUserId!; const sticker = action.type === 'giftCode' ? selectGiftStickerForDuration(global, action.months) : selectGiftStickerForStars(global, action.stars); const canPlayAnimatedEmojis = selectCanPlayAnimatedEmojis(global); - const channel = selectChat(global, action.boostPeerId!); + const channel = action.boostPeerId ? selectChat(global, action.boostPeerId) : undefined; return { + currentUserId, sticker, canPlayAnimatedEmojis, channel, diff --git a/src/components/middle/message/helpers/messageActions.tsx b/src/components/middle/message/helpers/messageActions.tsx index 0fe64edf4..250fcea73 100644 --- a/src/components/middle/message/helpers/messageActions.tsx +++ b/src/components/middle/message/helpers/messageActions.tsx @@ -35,16 +35,23 @@ export function translateWithYou( key: K, isYou: boolean, variables: VariablesForKey, - options?: { pluralValue?: number; asText?: boolean; isMarkdown?: boolean }, + options?: { + pluralValue?: number; + asText?: boolean; + isMarkdown?: boolean; + renderTextFilters?: string[]; + }, ): TeactNode { - const { pluralValue, asText, isMarkdown } = options || {}; + const { pluralValue, asText, isMarkdown, renderTextFilters } = options || {}; const translationKey = isYou ? (`${key}You` as LangKey) : key; return lang( // @ts-ignore -- I have no idea if this even possible to type correctly translationKey, variables, - { withNodes: !asText, isMarkdown, pluralValue }, + { + withNodes: !asText, isMarkdown, pluralValue, renderTextFilters, + }, ); } diff --git a/src/components/modals/giftcode/GiftCodeModal.tsx b/src/components/modals/giftcode/GiftCodeModal.tsx index 51c43809d..510d7c8be 100644 --- a/src/components/modals/giftcode/GiftCodeModal.tsx +++ b/src/components/modals/giftcode/GiftCodeModal.tsx @@ -75,18 +75,30 @@ const GiftCodeModal = ({ ); - const tableData = [ + const tableData: TableData = [ [lang('BoostingFrom'), fromId ? { chatId: fromId } : lang('BoostingNoRecipient')], [lang('BoostingTo'), info.toId ? { chatId: info.toId } : lang('BoostingNoRecipient')], [lang('BoostingGift'), lang('BoostingTelegramPremiumFor', lang('Months', info.months, 'i'))], - [lang('BoostingReason'), ( - - {info.isFromGiveaway && !info.toId ? lang('BoostingIncompleteGiveaway') - : lang(info.isFromGiveaway ? 'BoostingGiveaway' : 'BoostingYouWereSelected')} - - )], - [lang('BoostingDate'), formatDateTimeToString(info.date * 1000, lang.code, true)], - ] satisfies TableData; + ]; + if (info.isFromGiveaway) { + tableData.push([ + lang('BoostingReason'), + ( + + {info.isFromGiveaway && !info.toId + ? lang('BoostingIncompleteGiveaway') + : lang('BoostingGiveaway')} + + ), + ]); + } + tableData.push([ + lang('BoostingDate'), + formatDateTimeToString(info.date * 1000, lang.code, true), + ]); const footer = ( diff --git a/src/types/language.d.ts b/src/types/language.d.ts index 330032420..24f3cc37f 100644 --- a/src/types/language.d.ts +++ b/src/types/language.d.ts @@ -1419,6 +1419,7 @@ export interface LangPair { 'ActionScreenshotTakenYou': undefined; 'ActionBotAppPlaceholder': undefined; 'ActionGiftTextUnknown': undefined; + 'ActionGiftTextUnknownYou': undefined; 'ActionGiftUniqueSent': undefined; 'ActionStarGiftUpgradedSelf': undefined; 'ActionStarGiftTransferredSelf': undefined; @@ -1524,7 +1525,6 @@ export interface LangPair { 'GiftSortByPrice': undefined; 'GiftSortByNumber': undefined; 'ContextMenuItemSelectAll': undefined; - 'ButtonSort': undefined; 'ValueGiftSortByDate': undefined; 'ValueGiftSortByPrice': undefined; 'ValueGiftSortByNumber': undefined; @@ -2759,6 +2759,14 @@ export interface LangPairPluralWithVariables { 'channel': V; 'amount': V; }; + 'ActionGiftCodeSubscriptionText': { + 'peer': V; + 'months': V; + }; + 'ActionGiftCodeSubscriptionTextYou': { + 'peer': V; + 'months': V; + }; 'ActionGiftPremiumTitle': { 'months': V; };