From 1cc5988c40261912aabdc63d7fd912626e98c530 Mon Sep 17 00:00:00 2001 From: John Preston Date: Mon, 27 Jan 2025 19:24:16 +0400 Subject: [PATCH] Improve gifts phrases. --- Telegram/Resources/langs/lang.strings | 6 ++ Telegram/SourceFiles/history/history_item.cpp | 83 +++++++++++++------ 2 files changed, 62 insertions(+), 27 deletions(-) diff --git a/Telegram/Resources/langs/lang.strings b/Telegram/Resources/langs/lang.strings index b7c533a4d..b282a3270 100644 --- a/Telegram/Resources/langs/lang.strings +++ b/Telegram/Resources/langs/lang.strings @@ -2026,13 +2026,19 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL "lng_action_gift_unique_sent" = "You sent a unique collectible item"; "lng_action_gift_upgraded" = "{user} turned the gift from you into a unique collectible"; "lng_action_gift_upgraded_channel" = "{user} turned this gift to {channel} into a unique collectible"; +"lng_action_gift_upgraded_self_channel" = "You turned this gift to {channel} into a unique collectible"; "lng_action_gift_upgraded_mine" = "You turned the gift from {user} into a unique collectible"; "lng_action_gift_upgraded_self" = "You turned this gift into a unique collectible"; "lng_action_gift_transferred" = "{user} transferred you a gift"; "lng_action_gift_transferred_channel" = "{user} transferred a gift to {channel}"; +"lng_action_gift_transferred_unknown" = "Someone transferred you a gift"; +"lng_action_gift_transferred_unknown_channel" = "Someone transferred a gift to {channel}"; +"lng_action_gift_transferred_self" = "You transferred a unique collectible"; +"lng_action_gift_transferred_self_channel" = "You transferred a gift to {channel}"; "lng_action_gift_transferred_mine" = "You transferred a gift to {user}"; "lng_action_gift_received_anonymous" = "Unknown user sent you a gift for {cost}"; "lng_action_gift_sent_channel" = "{user} sent a gift to {name} for {cost}"; +"lng_action_gift_sent_self_channel" = "You sent a gift to {name} for {cost}"; "lng_action_gift_self_bought" = "You bought a gift for {cost}"; "lng_action_gift_self_subtitle" = "Saved Gift"; "lng_action_gift_self_about#one" = "Display this gift on your page or convert it to **{count}** Star."; diff --git a/Telegram/SourceFiles/history/history_item.cpp b/Telegram/SourceFiles/history/history_item.cpp index 719ae4f59..b589f482f 100644 --- a/Telegram/SourceFiles/history/history_item.cpp +++ b/Telegram/SourceFiles/history/history_item.cpp @@ -5456,17 +5456,28 @@ void HistoryItem::setServiceMessageByAction(const MTPmessageAction &action) { const auto from = fromId ? peer->owner().peer(fromId) : peer; const auto channel = peer->owner().channel( peerToChannel(giftPeer)); - result.links.push_back(from->createOpenLink()); - result.links.push_back(channel->createOpenLink()); - result.text = 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, - cost, - Ui::Text::WithEntities); + if (from->isSelf()) { + result.links.push_back(channel->createOpenLink()); + result.text = tr::lng_action_gift_sent_self_channel( + tr::now, + lt_name, + Ui::Text::Link(channel->name(), 1), + lt_cost, + cost, + Ui::Text::WithEntities); + } else { + result.links.push_back(from->createOpenLink()); + result.links.push_back(channel->createOpenLink()); + result.text = 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, + cost, + Ui::Text::WithEntities); + } } else if (anonymous || _history->peer->isSelf()) { result.text = (anonymous ? tr::lng_action_gift_received_anonymous @@ -5512,24 +5523,33 @@ void HistoryItem::setServiceMessageByAction(const MTPmessageAction &action) { if (toChannel) { const auto channel = peer->owner().channel( peerToChannel(giftPeer)); - result.links.push_back(from->createOpenLink()); + 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)( + 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)( + tr::now, + lt_channel, + Ui::Text::Link(channel->name(), 1), + Ui::Text::WithEntities); + } result.links.push_back(channel->createOpenLink()); - result.text = (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.links.push_back(peer->createOpenLink()); - result.text = _history->peer->isSelf() - ? tr::lng_action_gift_upgraded_self( - tr::now, - Ui::Text::WithEntities) - : (action.is_upgrade() + if (!from->isServiceUser() && !_history->peer->isSelf()) { + result.links.push_back(from->createOpenLink()); + result.text = (action.is_upgrade() ? (isSelf ? tr::lng_action_gift_upgraded_mine : tr::lng_action_gift_upgraded) @@ -5540,6 +5560,15 @@ void HistoryItem::setServiceMessageByAction(const MTPmessageAction &action) { lt_user, Ui::Text::Link(from->shortName(), 1), // Link 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)( + tr::now, + Ui::Text::WithEntities); + } } return result; };