From 0605c7b2bce175be8e924406e396606b6ed07448 Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Mon, 3 Mar 2025 13:33:12 +0300 Subject: [PATCH] Added ability to display possible currency earn in megagroups in future. --- .../earn/info_channel_earn_list.cpp | 26 ++++++++++++++----- .../earn/info_channel_earn_widget.h | 1 + 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/Telegram/SourceFiles/info/channel_statistics/earn/info_channel_earn_list.cpp b/Telegram/SourceFiles/info/channel_statistics/earn/info_channel_earn_list.cpp index 302975afe..bac05ef0c 100644 --- a/Telegram/SourceFiles/info/channel_statistics/earn/info_channel_earn_list.cpp +++ b/Telegram/SourceFiles/info/channel_statistics/earn/info_channel_earn_list.cpp @@ -326,6 +326,9 @@ void InnerWidget::load() { ) | rpl::start_with_error_done([=](const QString &error) { if (isMegagroup) { _state.currencyEarn = {}; + if (error == u"BROADCAST_REQUIRED"_q) { + _state.canViewCurrencyMegagroupEarn = false; + } nextRequests(); } else { show->showToast(error); @@ -343,10 +346,17 @@ void InnerWidget::fill() { ? _peer->asUser() : nullptr; const auto channel = _peer->asChannel(); - const auto canViewCurrencyEarn = channel - ? ((channel->flags() & ChannelDataFlag::CanViewRevenue) - && !channel->isMegagroup()) - : true; + const auto canViewCurrencyEarn = [&] { + if (!channel) { + return true; + } else if (!(channel->flags() & ChannelDataFlag::CanViewRevenue)) { + return false; + } else if (channel->isMegagroup()) { + return _state.canViewCurrencyMegagroupEarn; + } else { + return true; + } + }(); const auto &data = canViewCurrencyEarn ? _state.currencyEarn : Data::EarnStatistics(); @@ -625,9 +635,11 @@ void InnerWidget::fill() { st::defaultBoxDividerLabelPadding, RectPart::Top | RectPart::Bottom)); }; - addAboutWithLearn(bot - ? tr::lng_channel_earn_about_bot - : tr::lng_channel_earn_about); + if (canViewCurrencyEarn) { + addAboutWithLearn(bot + ? tr::lng_channel_earn_about_bot + : tr::lng_channel_earn_about); + } { using Type = Statistic::ChartViewType; Ui::AddSkip(container); diff --git a/Telegram/SourceFiles/info/channel_statistics/earn/info_channel_earn_widget.h b/Telegram/SourceFiles/info/channel_statistics/earn/info_channel_earn_widget.h index becd834c6..031b404d9 100644 --- a/Telegram/SourceFiles/info/channel_statistics/earn/info_channel_earn_widget.h +++ b/Telegram/SourceFiles/info/channel_statistics/earn/info_channel_earn_widget.h @@ -34,6 +34,7 @@ public: Data::CreditsEarnStatistics creditsEarn; Data::CreditsStatusSlice creditsStatusSlice; PeerId premiumBotId = PeerId(0); + bool canViewCurrencyMegagroupEarn = true; }; void setState(SavedState states);