Added ability to display possible currency earn in megagroups in future.

This commit is contained in:
23rd 2025-03-03 13:33:12 +03:00 committed by John Preston
parent 8e83a55143
commit 0605c7b2bc
2 changed files with 20 additions and 7 deletions

View file

@ -326,6 +326,9 @@ void InnerWidget::load() {
) | rpl::start_with_error_done([=](const QString &error) { ) | rpl::start_with_error_done([=](const QString &error) {
if (isMegagroup) { if (isMegagroup) {
_state.currencyEarn = {}; _state.currencyEarn = {};
if (error == u"BROADCAST_REQUIRED"_q) {
_state.canViewCurrencyMegagroupEarn = false;
}
nextRequests(); nextRequests();
} else { } else {
show->showToast(error); show->showToast(error);
@ -343,10 +346,17 @@ void InnerWidget::fill() {
? _peer->asUser() ? _peer->asUser()
: nullptr; : nullptr;
const auto channel = _peer->asChannel(); const auto channel = _peer->asChannel();
const auto canViewCurrencyEarn = channel const auto canViewCurrencyEarn = [&] {
? ((channel->flags() & ChannelDataFlag::CanViewRevenue) if (!channel) {
&& !channel->isMegagroup()) return true;
: true; } else if (!(channel->flags() & ChannelDataFlag::CanViewRevenue)) {
return false;
} else if (channel->isMegagroup()) {
return _state.canViewCurrencyMegagroupEarn;
} else {
return true;
}
}();
const auto &data = canViewCurrencyEarn const auto &data = canViewCurrencyEarn
? _state.currencyEarn ? _state.currencyEarn
: Data::EarnStatistics(); : Data::EarnStatistics();
@ -625,9 +635,11 @@ void InnerWidget::fill() {
st::defaultBoxDividerLabelPadding, st::defaultBoxDividerLabelPadding,
RectPart::Top | RectPart::Bottom)); RectPart::Top | RectPart::Bottom));
}; };
addAboutWithLearn(bot if (canViewCurrencyEarn) {
? tr::lng_channel_earn_about_bot addAboutWithLearn(bot
: tr::lng_channel_earn_about); ? tr::lng_channel_earn_about_bot
: tr::lng_channel_earn_about);
}
{ {
using Type = Statistic::ChartViewType; using Type = Statistic::ChartViewType;
Ui::AddSkip(container); Ui::AddSkip(container);

View file

@ -34,6 +34,7 @@ public:
Data::CreditsEarnStatistics creditsEarn; Data::CreditsEarnStatistics creditsEarn;
Data::CreditsStatusSlice creditsStatusSlice; Data::CreditsStatusSlice creditsStatusSlice;
PeerId premiumBotId = PeerId(0); PeerId premiumBotId = PeerId(0);
bool canViewCurrencyMegagroupEarn = true;
}; };
void setState(SavedState states); void setState(SavedState states);