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) {
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);

View file

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