diff --git a/Telegram/SourceFiles/api/api_credits.cpp b/Telegram/SourceFiles/api/api_credits.cpp index 1604d6d5ce..453d9536f3 100644 --- a/Telegram/SourceFiles/api/api_credits.cpp +++ b/Telegram/SourceFiles/api/api_credits.cpp @@ -10,6 +10,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "apiwrap.h" #include "base/unixtime.h" #include "data/data_peer.h" +#include "data/data_photo.h" #include "data/data_session.h" #include "main/main_app_config.h" #include "main/main_session.h" @@ -21,12 +22,24 @@ namespace Api { namespace { [[nodiscard]] Data::CreditsHistoryEntry HistoryFromTL( - const MTPStarsTransaction &tl) { + const MTPStarsTransaction &tl, + not_null peer) { using HistoryPeerTL = MTPDstarsTransactionPeer; + const auto photo = tl.data().vphoto() + ? peer->owner().photoFromWeb(*tl.data().vphoto(), ImageLocation()) + : nullptr; return Data::CreditsHistoryEntry{ .id = qs(tl.data().vid()), - .credits = tl.data().vstars().v, + .title = qs(tl.data().vtitle().value_or_empty()), + .description = qs(tl.data().vdescription().value_or_empty()), .date = base::unixtime::parse(tl.data().vdate().v), + .photoId = photo ? photo->id : 0, + .credits = tl.data().vstars().v, + .bareId = tl.data().vpeer().match([](const HistoryPeerTL &p) { + return peerFromMTP(p.vpeer()); + }, [](const auto &) { + return PeerId(0); + }).value, .peerType = tl.data().vpeer().match([](const HistoryPeerTL &) { return Data::CreditsHistoryEntry::PeerType::Peer; }, [](const MTPDstarsTransactionPeerPlayMarket &) { @@ -40,11 +53,6 @@ namespace { }, [](const MTPDstarsTransactionPeerPremiumBot &) { return Data::CreditsHistoryEntry::PeerType::PremiumBot; }), - .bareId = tl.data().vpeer().match([](const HistoryPeerTL &p) { - return peerFromMTP(p.vpeer()); - }, [](const auto &) { - return PeerId(0); - }).value, }; } @@ -56,7 +64,9 @@ namespace { return Data::CreditsStatusSlice{ .list = ranges::views::all( status.data().vhistory().v - ) | ranges::views::transform(HistoryFromTL) | ranges::to_vector, + ) | ranges::views::transform([&](const MTPStarsTransaction &tl) { + return HistoryFromTL(tl, peer); + }) | ranges::to_vector, .balance = status.data().vbalance().v, .allLoaded = !status.data().vnext_offset().has_value(), .token = qs(status.data().vnext_offset().value_or_empty()), diff --git a/Telegram/SourceFiles/data/data_credits.h b/Telegram/SourceFiles/data/data_credits.h index 7a241c87a9..af830e26c8 100644 --- a/Telegram/SourceFiles/data/data_credits.h +++ b/Telegram/SourceFiles/data/data_credits.h @@ -20,6 +20,7 @@ struct CreditTopupOption final { using CreditTopupOptions = std::vector; struct CreditsHistoryEntry final { + using PhotoId = uint64; enum class PeerType { Peer, AppStore, @@ -29,10 +30,13 @@ struct CreditsHistoryEntry final { PremiumBot, }; QString id; - uint64 credits = 0; + QString title; + QString description; QDateTime date; - PeerType peerType; + PhotoId photoId = 0; + uint64 credits = 0; uint64 bareId = 0; + PeerType peerType; }; struct CreditsStatusSlice final { diff --git a/Telegram/SourceFiles/info/channel_statistics/boosts/giveaway/giveaway.style b/Telegram/SourceFiles/info/channel_statistics/boosts/giveaway/giveaway.style index ef705ab2a8..2715dfe958 100644 --- a/Telegram/SourceFiles/info/channel_statistics/boosts/giveaway/giveaway.style +++ b/Telegram/SourceFiles/info/channel_statistics/boosts/giveaway/giveaway.style @@ -96,8 +96,8 @@ giveawayGiftCodeValue: FlatLabel(defaultFlatLabel) { } } giveawayGiftCodeValueMultiline: FlatLabel(giveawayGiftCodeValue) { - minWidth: 100px; - maxHeight: 0px; + minWidth: 128px; + maxHeight: 100px; } giveawayGiftCodeValueMargin: margins(13px, 9px, 13px, 9px); giveawayGiftCodePeerMargin: margins(11px, 6px, 11px, 4px); diff --git a/Telegram/SourceFiles/payments/payments_non_panel_process.cpp b/Telegram/SourceFiles/payments/payments_non_panel_process.cpp index 2369d3d5d4..5ff5a07f36 100644 --- a/Telegram/SourceFiles/payments/payments_non_panel_process.cpp +++ b/Telegram/SourceFiles/payments/payments_non_panel_process.cpp @@ -10,6 +10,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "base/unixtime.h" #include "boxes/send_credits_box.h" #include "data/data_credits.h" +#include "data/data_photo.h" #include "history/history_item.h" #include "history/history_item_components.h" #include "payments/payments_checkout_process.h" // NonPanelPaymentForm. @@ -45,10 +46,13 @@ Fn ProcessNonPanelPaymentFormFactory( const auto receipt = *r; const auto entry = Data::CreditsHistoryEntry{ .id = receipt->id, - .credits = receipt->credits, + .title = receipt->title, + .description = receipt->description, .date = base::unixtime::parse(receipt->date), - .peerType = Data::CreditsHistoryEntry::PeerType::Peer, + .photoId = receipt->photo ? receipt->photo->id : 0, + .credits = receipt->credits, .bareId = receipt->peerId.value, + .peerType = Data::CreditsHistoryEntry::PeerType::Peer, }; controller->uiShow()->show(Box( Settings::ReceiptCreditsBox, diff --git a/Telegram/SourceFiles/settings/settings_credits.cpp b/Telegram/SourceFiles/settings/settings_credits.cpp index e9a01aa0a3..0eec25cf4e 100644 --- a/Telegram/SourceFiles/settings/settings_credits.cpp +++ b/Telegram/SourceFiles/settings/settings_credits.cpp @@ -764,7 +764,14 @@ void ReceiptCreditsBox( : e.bareId ? controller->session().data().peer(PeerId(e.bareId)).get() : nullptr; - if (peer) { + const auto photo = e.photoId + ? controller->session().data().photo(e.photoId).get() + : nullptr; + if (photo) { + content->add(object_ptr>( + content, + HistoryEntryPhoto(content, photo, stUser.photoSize))); + } else if (peer) { content->add(object_ptr>( content, object_ptr(content, peer, stUser))); @@ -792,7 +799,10 @@ void ReceiptCreditsBox( box, object_ptr( box, - rpl::single(peer + rpl::single( + !e.title.isEmpty() + ? e.title + : peer ? peer->name() : Ui::GenerateEntryName(e).text), st::creditsBoxAboutTitle))); @@ -838,6 +848,16 @@ void ReceiptCreditsBox( }, amount->lifetime()); } + if (!e.description.isEmpty()) { + Ui::AddSkip(content); + box->addRow(object_ptr>( + box, + object_ptr( + box, + rpl::single(e.description), + st::defaultFlatLabel))); + } + Ui::AddSkip(content); Ui::AddSkip(content);