From 3375ff61528b51e981900d7f45c01c74e118b22a Mon Sep 17 00:00:00 2001 From: John Preston Date: Wed, 23 Apr 2025 18:47:46 +0400 Subject: [PATCH] Use correct phrases for the resold gifts. --- .../SourceFiles/boxes/transfer_gift_box.cpp | 8 +- Telegram/SourceFiles/history/history_item.cpp | 102 +++++++++++++----- 2 files changed, 80 insertions(+), 30 deletions(-) diff --git a/Telegram/SourceFiles/boxes/transfer_gift_box.cpp b/Telegram/SourceFiles/boxes/transfer_gift_box.cpp index cb6260aa89..c761cc218b 100644 --- a/Telegram/SourceFiles/boxes/transfer_gift_box.cpp +++ b/Telegram/SourceFiles/boxes/transfer_gift_box.cpp @@ -479,14 +479,16 @@ void BuyResaleGift( not_null to, std::shared_ptr gift, Fn done) { - Expects(to->isUser()); - auto formDone = [=]( Payments::CheckoutResult result, const MTPUpdates *updates) { done(result); if (result == Payments::CheckoutResult::Paid) { - AssertIsDebug(Refresh owners gifts list, refresh self list); + gift->starsForResale = 0; + to->owner().notifyGiftUpdate({ + .slug = gift->slug, + .action = Data::GiftUpdate::Action::ResaleChange, + }); Ui::ShowResaleGiftBoughtToast(show, to, *gift); } }; diff --git a/Telegram/SourceFiles/history/history_item.cpp b/Telegram/SourceFiles/history/history_item.cpp index 5563629ad2..1cd7a225b7 100644 --- a/Telegram/SourceFiles/history/history_item.cpp +++ b/Telegram/SourceFiles/history/history_item.cpp @@ -5611,6 +5611,11 @@ void HistoryItem::setServiceMessageByAction(const MTPmessageAction &action) { const MTPDmessageActionStarGiftUnique &action) { auto result = PreparedServiceText(); const auto isSelf = _from->isSelf(); + const auto resaleStars = action.vresale_stars().value_or_empty(); + const auto resaleCost = TextWithEntities{ resaleStars + ? tr::lng_action_gift_for_stars(tr::now, lt_count, resaleStars) + : QString() + }; const auto giftPeer = action.vpeer() ? peerFromMTP(*action.vpeer()) : PeerId(); @@ -5626,49 +5631,92 @@ void HistoryItem::setServiceMessageByAction(const MTPmessageAction &action) { peerToChannel(giftPeer)); if (!from->isServiceUser() && !from->isSelf()) { result.links.push_back(from->createOpenLink()); - result.text = (action.is_upgrade() - ? tr::lng_action_gift_upgraded_channel - : tr::lng_action_gift_transferred_channel)( + if (resaleStars) { + result.links.push_back(channel->createOpenLink()); + } + result.text = resaleStars + ? tr::lng_action_gift_sent_channel( tr::now, lt_user, Ui::Text::Link(from->shortName(), 1), - lt_channel, + lt_name, Ui::Text::Link(channel->name(), 2), - Ui::Text::WithEntities); + lt_cost, + resaleCost, + Ui::Text::WithEntities) + : (action.is_upgrade() + ? tr::lng_action_gift_upgraded_channel + : tr::lng_action_gift_transferred_channel)( + tr::now, + lt_user, + Ui::Text::Link(from->shortName(), 1), + lt_channel, + Ui::Text::Link(channel->name(), 2), + Ui::Text::WithEntities); } else { - result.text = (from->isServiceUser() - ? tr::lng_action_gift_transferred_unknown_channel - : action.is_upgrade() - ? tr::lng_action_gift_upgraded_self_channel - : tr::lng_action_gift_transferred_self_channel)( + result.text = resaleStars + ? tr::lng_action_gift_sent_self_channel( tr::now, - lt_channel, + lt_name, Ui::Text::Link(channel->name(), 1), - Ui::Text::WithEntities); + lt_cost, + resaleCost, + Ui::Text::WithEntities) + : (from->isServiceUser() + ? tr::lng_action_gift_transferred_unknown_channel + : action.is_upgrade() + ? tr::lng_action_gift_upgraded_self_channel + : tr::lng_action_gift_transferred_self_channel)( + tr::now, + lt_channel, + Ui::Text::Link(channel->name(), 1), + Ui::Text::WithEntities); } result.links.push_back(channel->createOpenLink()); } else { if (!from->isServiceUser() && !_history->peer->isSelf()) { - result.links.push_back(from->createOpenLink()); - result.text = (action.is_upgrade() + if (!resaleStars || !isSelf) { + result.links.push_back(from->createOpenLink()); + } + result.text = resaleStars ? (isSelf - ? tr::lng_action_gift_upgraded_mine - : tr::lng_action_gift_upgraded) - : (isSelf - ? tr::lng_action_gift_transferred_mine - : tr::lng_action_gift_transferred))( + ? tr::lng_action_gift_sent( + tr::now, + lt_cost, + resaleCost, + Ui::Text::WithEntities) + : tr::lng_action_gift_received( tr::now, lt_user, - Ui::Text::Link(from->shortName(), 1), // Link 1. - Ui::Text::WithEntities); + Ui::Text::Link(peer->shortName(), 1), // Link 1. + lt_cost, + resaleCost, + Ui::Text::WithEntities)) + : (action.is_upgrade() + ? (isSelf + ? tr::lng_action_gift_upgraded_mine + : tr::lng_action_gift_upgraded) + : (isSelf + ? tr::lng_action_gift_transferred_mine + : tr::lng_action_gift_transferred))( + tr::now, + lt_user, + Ui::Text::Link(from->shortName(), 1), + Ui::Text::WithEntities); } else { - result.text = (from->isServiceUser() - ? tr::lng_action_gift_transferred_unknown - : action.is_upgrade() - ? tr::lng_action_gift_upgraded_self - : tr::lng_action_gift_transferred_self)( + result.text = resaleStars + ? tr::lng_action_gift_self_bought( tr::now, - Ui::Text::WithEntities); + lt_cost, + resaleCost, + Ui::Text::WithEntities) + : (from->isServiceUser() + ? tr::lng_action_gift_transferred_unknown + : action.is_upgrade() + ? tr::lng_action_gift_upgraded_self + : tr::lng_action_gift_transferred_self)( + tr::now, + Ui::Text::WithEntities); } } return result;