diff --git a/Telegram/Resources/langs/lang.strings b/Telegram/Resources/langs/lang.strings index 1ec4ebbc69..8e20054bb9 100644 --- a/Telegram/Resources/langs/lang.strings +++ b/Telegram/Resources/langs/lang.strings @@ -2823,6 +2823,11 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL "lng_credits_box_history_entry_reaction_name" = "Star Reaction"; "lng_credits_box_history_entry_subscription" = "Monthly subscription fee"; "lng_credits_box_history_entry_gift_upgrade" = "Collectible Upgrade"; +"lng_credits_box_history_entry_gift_sold" = "Gift Sale"; +"lng_credits_box_history_entry_gift_bought" = "Gift Purchase"; +"lng_credits_box_history_entry_gift_sold_to" = "To"; +"lng_credits_box_history_entry_gift_full_price" = "Full Price"; +"lng_credits_box_history_entry_gift_bought_from" = "From"; "lng_credits_subscription_section" = "My subscriptions"; "lng_credits_box_subscription_title" = "Subscription"; diff --git a/Telegram/SourceFiles/api/api_credits.cpp b/Telegram/SourceFiles/api/api_credits.cpp index 103554a5b4..ec49947ebf 100644 --- a/Telegram/SourceFiles/api/api_credits.cpp +++ b/Telegram/SourceFiles/api/api_credits.cpp @@ -157,6 +157,7 @@ constexpr auto kTransactionsLimit = 100; .converted = stargift && incoming, .stargift = stargift.has_value(), .giftUpgraded = tl.data().is_stargift_upgrade(), + .giftResale = tl.data().is_stargift_resale(), .reaction = tl.data().is_reaction(), .refunded = tl.data().is_refund(), .pending = tl.data().is_pending(), diff --git a/Telegram/SourceFiles/boxes/gift_premium_box.cpp b/Telegram/SourceFiles/boxes/gift_premium_box.cpp index a2dc824d57..ef6125185a 100644 --- a/Telegram/SourceFiles/boxes/gift_premium_box.cpp +++ b/Telegram/SourceFiles/boxes/gift_premium_box.cpp @@ -1627,7 +1627,17 @@ void AddCreditsHistoryEntryTable( const auto starrefRecipientId = PeerId(entry.starrefRecipientId); const auto session = &show->session(); if (entry.starrefCommission) { - if (entry.starrefAmount) { + if (entry.giftResale && entry.starrefCommission < 1000) { + const auto full = int(base::SafeRound(entry.credits.value() + / (1. - (entry.starrefCommission / 1000.)))); + auto value = Ui::Text::IconEmoji(&st::starIconEmojiColored); + const auto starsText = Lang::FormatStarsAmountDecimal( + StarsAmount{ full }); + AddTableRow( + table, + tr::lng_credits_box_history_entry_gift_full_price(), + rpl::single(value.append(' ' + starsText))); + } else if (entry.starrefAmount) { AddTableRow( table, tr::lng_star_ref_commission_title(), @@ -1641,7 +1651,7 @@ void AddCreditsHistoryEntryTable( Ui::Text::WithEntities)); } } - if (starrefRecipientId && entry.starrefAmount) { + if (starrefRecipientId && entry.starrefAmount && !entry.giftResale) { AddTableRow( table, tr::lng_credits_box_history_entry_affiliate(), @@ -1651,7 +1661,9 @@ void AddCreditsHistoryEntryTable( if (peerId && entry.starrefCommission) { AddTableRow( table, - (entry.starrefAmount + (entry.giftResale + ? tr::lng_credits_box_history_entry_gift_sold_to + : entry.starrefAmount ? tr::lng_credits_box_history_entry_referred : tr::lng_credits_box_history_entry_miniapp)(), show, @@ -1662,6 +1674,8 @@ void AddCreditsHistoryEntryTable( ? tr::lng_credits_box_history_entry_referred() : entry.in ? tr::lng_credits_box_history_entry_peer_in() + : entry.giftResale + ? tr::lng_credits_box_history_entry_gift_bought_from() : entry.giftUpgraded ? tr::lng_credits_box_history_entry_gift_from() : tr::lng_credits_box_history_entry_peer(); diff --git a/Telegram/SourceFiles/data/data_credits.h b/Telegram/SourceFiles/data/data_credits.h index 1405492213..0432097980 100644 --- a/Telegram/SourceFiles/data/data_credits.h +++ b/Telegram/SourceFiles/data/data_credits.h @@ -95,6 +95,7 @@ struct CreditsHistoryEntry final { bool giftTransferred : 1 = false; bool giftRefunded : 1 = false; bool giftUpgraded : 1 = false; + bool giftResale : 1 = false; bool giftPinned : 1 = false; bool savedToProfile : 1 = false; bool fromGiftsList : 1 = false; diff --git a/Telegram/SourceFiles/ui/effects/credits_graphics.cpp b/Telegram/SourceFiles/ui/effects/credits_graphics.cpp index 64f21566e3..3ffe154eb7 100644 --- a/Telegram/SourceFiles/ui/effects/credits_graphics.cpp +++ b/Telegram/SourceFiles/ui/effects/credits_graphics.cpp @@ -618,6 +618,10 @@ TextWithEntities GenerateEntryName(const Data::CreditsHistoryEntry &entry) { ? tr::lng_credits_box_history_entry_reaction_name : entry.giftUpgraded ? tr::lng_credits_box_history_entry_gift_upgrade + : entry.giftResale + ? (entry.in + ? tr::lng_credits_box_history_entry_gift_sold + : tr::lng_credits_box_history_entry_gift_bought) : entry.bareGiveawayMsgId ? tr::lng_credits_box_history_entry_giveaway_name : entry.converted