Use correct phrases for the resold gifts.

This commit is contained in:
John Preston 2025-04-23 18:47:46 +04:00
parent 80fc58f83e
commit 3375ff6152
2 changed files with 80 additions and 30 deletions

View file

@ -479,14 +479,16 @@ void BuyResaleGift(
not_null<PeerData*> to, not_null<PeerData*> to,
std::shared_ptr<Data::UniqueGift> gift, std::shared_ptr<Data::UniqueGift> gift,
Fn<void(Payments::CheckoutResult)> done) { Fn<void(Payments::CheckoutResult)> done) {
Expects(to->isUser());
auto formDone = [=]( auto formDone = [=](
Payments::CheckoutResult result, Payments::CheckoutResult result,
const MTPUpdates *updates) { const MTPUpdates *updates) {
done(result); done(result);
if (result == Payments::CheckoutResult::Paid) { 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); Ui::ShowResaleGiftBoughtToast(show, to, *gift);
} }
}; };

View file

@ -5611,6 +5611,11 @@ void HistoryItem::setServiceMessageByAction(const MTPmessageAction &action) {
const MTPDmessageActionStarGiftUnique &action) { const MTPDmessageActionStarGiftUnique &action) {
auto result = PreparedServiceText(); auto result = PreparedServiceText();
const auto isSelf = _from->isSelf(); 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() const auto giftPeer = action.vpeer()
? peerFromMTP(*action.vpeer()) ? peerFromMTP(*action.vpeer())
: PeerId(); : PeerId();
@ -5626,7 +5631,20 @@ void HistoryItem::setServiceMessageByAction(const MTPmessageAction &action) {
peerToChannel(giftPeer)); peerToChannel(giftPeer));
if (!from->isServiceUser() && !from->isSelf()) { if (!from->isServiceUser() && !from->isSelf()) {
result.links.push_back(from->createOpenLink()); result.links.push_back(from->createOpenLink());
result.text = (action.is_upgrade() 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_name,
Ui::Text::Link(channel->name(), 2),
lt_cost,
resaleCost,
Ui::Text::WithEntities)
: (action.is_upgrade()
? tr::lng_action_gift_upgraded_channel ? tr::lng_action_gift_upgraded_channel
: tr::lng_action_gift_transferred_channel)( : tr::lng_action_gift_transferred_channel)(
tr::now, tr::now,
@ -5636,7 +5654,15 @@ void HistoryItem::setServiceMessageByAction(const MTPmessageAction &action) {
Ui::Text::Link(channel->name(), 2), Ui::Text::Link(channel->name(), 2),
Ui::Text::WithEntities); Ui::Text::WithEntities);
} else { } else {
result.text = (from->isServiceUser() result.text = resaleStars
? tr::lng_action_gift_sent_self_channel(
tr::now,
lt_name,
Ui::Text::Link(channel->name(), 1),
lt_cost,
resaleCost,
Ui::Text::WithEntities)
: (from->isServiceUser()
? tr::lng_action_gift_transferred_unknown_channel ? tr::lng_action_gift_transferred_unknown_channel
: action.is_upgrade() : action.is_upgrade()
? tr::lng_action_gift_upgraded_self_channel ? tr::lng_action_gift_upgraded_self_channel
@ -5649,8 +5675,24 @@ void HistoryItem::setServiceMessageByAction(const MTPmessageAction &action) {
result.links.push_back(channel->createOpenLink()); result.links.push_back(channel->createOpenLink());
} else { } else {
if (!from->isServiceUser() && !_history->peer->isSelf()) { if (!from->isServiceUser() && !_history->peer->isSelf()) {
if (!resaleStars || !isSelf) {
result.links.push_back(from->createOpenLink()); result.links.push_back(from->createOpenLink());
result.text = (action.is_upgrade() }
result.text = resaleStars
? (isSelf
? 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(peer->shortName(), 1), // Link 1.
lt_cost,
resaleCost,
Ui::Text::WithEntities))
: (action.is_upgrade()
? (isSelf ? (isSelf
? tr::lng_action_gift_upgraded_mine ? tr::lng_action_gift_upgraded_mine
: tr::lng_action_gift_upgraded) : tr::lng_action_gift_upgraded)
@ -5659,10 +5701,16 @@ void HistoryItem::setServiceMessageByAction(const MTPmessageAction &action) {
: tr::lng_action_gift_transferred))( : tr::lng_action_gift_transferred))(
tr::now, tr::now,
lt_user, lt_user,
Ui::Text::Link(from->shortName(), 1), // Link 1. Ui::Text::Link(from->shortName(), 1),
Ui::Text::WithEntities); Ui::Text::WithEntities);
} else { } else {
result.text = (from->isServiceUser() result.text = resaleStars
? tr::lng_action_gift_self_bought(
tr::now,
lt_cost,
resaleCost,
Ui::Text::WithEntities)
: (from->isServiceUser()
? tr::lng_action_gift_transferred_unknown ? tr::lng_action_gift_transferred_unknown
: action.is_upgrade() : action.is_upgrade()
? tr::lng_action_gift_upgraded_self ? tr::lng_action_gift_upgraded_self