Skip to content

Commit

Permalink
Removed currency stat from channel earn section when it's not available.
Browse files Browse the repository at this point in the history
  • Loading branch information
23rd committed Aug 16, 2024
1 parent f2ea0ed commit bfbdf1b
Showing 1 changed file with 16 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,13 @@ void InnerWidget::load() {

void InnerWidget::fill() {
const auto container = this;
const auto &data = _state.currencyEarn;
const auto channel = _peer->asChannel();
const auto canViewCurrencyEarn = channel
? (channel->flags() & ChannelDataFlag::CanViewRevenue)
: true;
const auto &data = canViewCurrencyEarn
? _state.currencyEarn
: Data::EarnStatistics();
const auto &creditsData = _state.creditsEarn;

auto currencyStateValue = rpl::single(
Expand Down Expand Up @@ -417,7 +423,6 @@ void InnerWidget::fill() {
const auto nonInteractive = base::unixtime::now() < kNonInteractivePeriod;

const auto session = &_peer->session();
const auto channel = _peer->asChannel();
const auto withdrawalEnabled = WithdrawalEnabled(session)
&& !nonInteractive;
const auto makeContext = [=](not_null<Ui::FlatLabel*> l) {
Expand Down Expand Up @@ -1486,10 +1491,15 @@ void InnerWidget::fill() {
[] {});
}
if (!isLocked) {
Api::RestrictSponsored(channel, value, [=](const QString &e) {
toggled->fire(false);
_controller->uiShow()->showToast(e);
});
const auto weak = Ui::MakeWeak(this);
const auto show = _controller->uiShow();
const auto failed = [=](const QString &e) {
if (weak.data()) {
toggled->fire(false);
show->showToast(e);
}
};
Api::RestrictSponsored(channel, value, failed);
}
}, button->lifetime());

Expand Down

0 comments on commit bfbdf1b

Please sign in to comment.