From bf0b85afd1022f260c876926fc3bc572d523e7ec Mon Sep 17 00:00:00 2001 From: John Preston Date: Tue, 5 Aug 2025 10:43:10 +0400 Subject: [PATCH] Improve posts search transaction entry view. --- Telegram/Resources/langs/lang.strings | 1 + .../SourceFiles/api/api_credits_history_entry.cpp | 1 + Telegram/SourceFiles/boxes/gift_premium_box.cpp | 3 ++- Telegram/SourceFiles/data/data_credits.h | 1 + Telegram/SourceFiles/dialogs/dialogs.style | 1 - .../statistics/info_statistics_list_controllers.cpp | 13 +++++-------- .../settings/settings_credits_graphics.cpp | 9 +++++++-- Telegram/SourceFiles/ui/effects/credits.style | 1 + .../SourceFiles/ui/effects/credits_graphics.cpp | 10 +++++++++- 9 files changed, 27 insertions(+), 13 deletions(-) diff --git a/Telegram/Resources/langs/lang.strings b/Telegram/Resources/langs/lang.strings index 88ac676494..e7cff1fa3d 100644 --- a/Telegram/Resources/langs/lang.strings +++ b/Telegram/Resources/langs/lang.strings @@ -2902,6 +2902,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL "lng_credits_box_history_entry_ads" = "Ads Platform"; "lng_credits_box_history_entry_premium_bot" = "Stars Top-Up"; "lng_credits_box_history_entry_currency_in" = "TON Top-Up"; +"lng_credits_box_history_entry_posts_search" = "Posts Search"; "lng_credits_box_history_entry_api" = "Paid Broadcast"; "lng_credits_box_history_entry_floodskip_about#one" = "{count} Message"; "lng_credits_box_history_entry_floodskip_about#other" = "{count} Messages"; diff --git a/Telegram/SourceFiles/api/api_credits_history_entry.cpp b/Telegram/SourceFiles/api/api_credits_history_entry.cpp index c6acdfeb6d..dbf616471d 100644 --- a/Telegram/SourceFiles/api/api_credits_history_entry.cpp +++ b/Telegram/SourceFiles/api/api_credits_history_entry.cpp @@ -153,6 +153,7 @@ Data::CreditsHistoryEntry CreditsHistoryEntryFromTL( .floodSkip = int(tl.data().vfloodskip_number().value_or(0)), .converted = stargift && incoming, .stargift = stargift.has_value(), + .postsSearch = tl.data().is_posts_search(), .giftUpgraded = tl.data().is_stargift_upgrade(), .giftResale = tl.data().is_stargift_resale(), .reaction = tl.data().is_reaction(), diff --git a/Telegram/SourceFiles/boxes/gift_premium_box.cpp b/Telegram/SourceFiles/boxes/gift_premium_box.cpp index 425e816af4..16fab1907a 100644 --- a/Telegram/SourceFiles/boxes/gift_premium_box.cpp +++ b/Telegram/SourceFiles/boxes/gift_premium_box.cpp @@ -1674,7 +1674,8 @@ void AddCreditsHistoryEntryTable( show, peerId); } - if (actorId || (!entry.starrefCommission && peerId)) { + if (!entry.postsSearch + && (actorId || (!entry.starrefCommission && peerId))) { auto text = entry.starrefCommission ? tr::lng_credits_box_history_entry_referred() : entry.in diff --git a/Telegram/SourceFiles/data/data_credits.h b/Telegram/SourceFiles/data/data_credits.h index b8d6d7f92d..aa7e29837b 100644 --- a/Telegram/SourceFiles/data/data_credits.h +++ b/Telegram/SourceFiles/data/data_credits.h @@ -98,6 +98,7 @@ struct CreditsHistoryEntry final { bool converted : 1 = false; bool anonymous : 1 = false; bool stargift : 1 = false; + bool postsSearch : 1 = false; bool giftTransferred : 1 = false; bool giftRefunded : 1 = false; bool giftUpgraded : 1 = false; diff --git a/Telegram/SourceFiles/dialogs/dialogs.style b/Telegram/SourceFiles/dialogs/dialogs.style index bef7689685..3484cbce3d 100644 --- a/Telegram/SourceFiles/dialogs/dialogs.style +++ b/Telegram/SourceFiles/dialogs/dialogs.style @@ -868,7 +868,6 @@ postsSearchIntroFooter: FlatLabel(defaultFlatLabel) { } } postsSearchIntroFooterMargin: margins(20px, 12px, 20px, 0px); - postsSearchIcon: icon {{ "box_search", windowFgActive }}; postsSearchIconPadding: margins(12px, 1px, 6px, 0px); postsSearchArrow: icon {{ "dialogs/mini_arrow", windowFgActive }}; diff --git a/Telegram/SourceFiles/info/statistics/info_statistics_list_controllers.cpp b/Telegram/SourceFiles/info/statistics/info_statistics_list_controllers.cpp index 319f3be521..a486a546e9 100644 --- a/Telegram/SourceFiles/info/statistics/info_statistics_list_controllers.cpp +++ b/Telegram/SourceFiles/info/statistics/info_statistics_list_controllers.cpp @@ -887,6 +887,8 @@ void CreditsRow::init() { tr::now, lt_count, _entry.paidMessagesCount) + : _entry.postsSearch + ? tr::lng_credits_box_history_entry_posts_search(tr::now) : ((!_entry.subscriptionUntil.isNull() && !isSpecial) || (_entry.giftUpgraded && !isSpecial) || (_entry.giftResale && !isSpecial) @@ -997,14 +999,9 @@ void CreditsRow::init() { } } if (!_paintUserpicCallback) { - _paintUserpicCallback = /*_entry.stargift - ? Ui::GenerateGiftStickerUserpicCallback( - _session, - _entry.bareGiftStickerId, - _context.repaint) - : */!isSpecial - ? PeerListRow::generatePaintUserpicCallback(false) - : Ui::GenerateCreditsPaintUserpicCallback(_entry); + _paintUserpicCallback = (isSpecial || _entry.postsSearch) + ? Ui::GenerateCreditsPaintUserpicCallback(_entry) + : PeerListRow::generatePaintUserpicCallback(false); } } diff --git a/Telegram/SourceFiles/settings/settings_credits_graphics.cpp b/Telegram/SourceFiles/settings/settings_credits_graphics.cpp index a52b1d0313..74ce6624a5 100644 --- a/Telegram/SourceFiles/settings/settings_credits_graphics.cpp +++ b/Telegram/SourceFiles/settings/settings_credits_graphics.cpp @@ -1282,7 +1282,10 @@ void GenericCreditsEntryBox( content->add(object_ptr>( content, GenericEntryPhoto(content, callback, stUser.photoSize))); - } else if (peer && !e.gift && !e.premiumMonthsForStars) { + } else if (peer + && !e.gift + && !e.premiumMonthsForStars + && !e.postsSearch) { if (e.subscriptionUntil.isNull() && s.until.isNull()) { content->add(object_ptr>( content, @@ -1368,7 +1371,7 @@ void GenericCreditsEntryBox( ? st::creditsHistoryEntryStarGiftSkip : st::creditsHistoryEntryGiftStickerSkip); }, icon->lifetime()); - } else { + } else if (!e.postsSearch) { const auto widget = content->add( object_ptr>( content, @@ -1405,6 +1408,8 @@ void GenericCreditsEntryBox( tr::now, lt_count, e.paidMessagesCount) + : e.postsSearch + ? tr::lng_credits_box_history_entry_posts_search(tr::now) : e.premiumMonthsForStars ? tr::lng_premium_summary_title(tr::now) : !e.title.isEmpty() diff --git a/Telegram/SourceFiles/ui/effects/credits.style b/Telegram/SourceFiles/ui/effects/credits.style index 4d963e2d2c..4b9fb822b3 100644 --- a/Telegram/SourceFiles/ui/effects/credits.style +++ b/Telegram/SourceFiles/ui/effects/credits.style @@ -99,6 +99,7 @@ tonIconEmojiInSmall: IconEmoji(tonIconEmoji) { } creditsHistoryEntryTypeAds: icon {{ "folders/folders_channels", premiumButtonFg }}; +creditsHistorySearchPostsIcon: icon {{ "box_search", historyPeerUserpicFg }}; creditsHistoryEntryGiftStickerSkip: -20px; creditsHistoryEntryGiftStickerSize: 150px; diff --git a/Telegram/SourceFiles/ui/effects/credits_graphics.cpp b/Telegram/SourceFiles/ui/effects/credits_graphics.cpp index 9131ea8352..676668463d 100644 --- a/Telegram/SourceFiles/ui/effects/credits_graphics.cpp +++ b/Telegram/SourceFiles/ui/effects/credits_graphics.cpp @@ -223,6 +223,12 @@ PaintRoundImageCallback GenerateCreditsPaintUserpicCallback( }; } const auto bg = [&]() -> EmptyUserpic::BgColors { + if (entry.postsSearch) { + return { + st::historyPeerSavedMessagesBg, + st::historyPeerSavedMessagesBg2, + }; + } switch (entry.peerType) { case Data::CreditsHistoryEntry::PeerType::API: return { st::historyPeer2UserpicBg, st::historyPeer2UserpicBg2 }; @@ -306,7 +312,9 @@ PaintRoundImageCallback GenerateCreditsPaintUserpicCallback( return [=](Painter &p, int x, int y, int outerWidth, int size) mutable { userpic->paintCircle(p, x, y, outerWidth, size); const auto rect = QRect(x, y, size, size); - ((entry.peerType == PeerType::AppStore) + (entry.postsSearch + ? st::creditsHistorySearchPostsIcon + : (entry.peerType == PeerType::AppStore) ? st::sessionIconiPhone : (entry.peerType == PeerType::PlayMarket) ? st::sessionIconAndroid