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,
std::shared_ptr<Data::UniqueGift> gift,
Fn<void(Payments::CheckoutResult)> 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);
}
};

View file

@ -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;