From 479e369d2962ee3528bed02615896e9d00229a53 Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Tue, 12 Nov 2024 23:26:31 +0300 Subject: [PATCH] Replaced list of credits subscriptions with peer list with widgets. --- .../info_statistics_list_controllers.cpp | 36 +++++++++++-------- 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/Telegram/SourceFiles/info/statistics/info_statistics_list_controllers.cpp b/Telegram/SourceFiles/info/statistics/info_statistics_list_controllers.cpp index 67fe36ed5..c01e7a9a2 100644 --- a/Telegram/SourceFiles/info/statistics/info_statistics_list_controllers.cpp +++ b/Telegram/SourceFiles/info/statistics/info_statistics_list_controllers.cpp @@ -10,6 +10,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "api/api_credits.h" #include "api/api_statistics.h" #include "boxes/peer_list_controllers.h" +#include "boxes/peer_list_widgets.h" #include "chat_helpers/stickers_gift_box_pack.h" #include "core/ui_integration.h" // Core::MarkedTextContext. #include "data/data_channel.h" @@ -1274,29 +1275,36 @@ void AddCreditsHistoryList( not_null bot, bool in, bool out, - bool subscription) { + bool subs) { struct State final { - State( - CreditsDescriptor d, - std::shared_ptr show) - : delegate(std::move(show)) - , controller(std::move(d)) { + State(CreditsDescriptor d) : controller(std::move(d)) { } - PeerListContentDelegateShow delegate; + std::optional creditsDelegate; + std::optional subscriptionDelegate; CreditsController controller; }; const auto state = container->lifetime().make_state( - CreditsDescriptor{ firstSlice, callback, bot, in, out, subscription }, - show); - - state->delegate.setContent(container->add( - object_ptr(container, &state->controller))); - state->controller.setDelegate(&state->delegate); + CreditsDescriptor{ firstSlice, callback, bot, in, out, subs }); + if (subs) { + state->subscriptionDelegate.emplace(); + state->subscriptionDelegate->setUiShow(show); + state->subscriptionDelegate->setContent(container->add( + object_ptr(container, &state->controller))); + state->controller.setDelegate(&(*state->subscriptionDelegate)); + } else { + state->creditsDelegate.emplace(show); + state->creditsDelegate->setContent(container->add( + object_ptr(container, &state->controller))); + state->controller.setDelegate(&(*state->creditsDelegate)); + } const auto wrap = container->add( object_ptr>( container, - CreateShowMoreButton(container, tr::lng_stories_show_more()))); + CreateShowMoreButton(container, tr::lng_stories_show_more())), + subs + ? QMargins() + : QMargins(0, -st::settingsButton.padding.top(), 0, 0)); const auto showMore = [=] { if (!state->controller.skipRequest()) {