mirror of
https://github.com/Qz3rK/tdesktop.git
synced 2026-07-03 14:15:08 +02:00
Added ability to display possible currency earn in megagroups in future.
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -34,6 +34,7 @@ public:
|
||||
Data::CreditsEarnStatistics creditsEarn;
|
||||
Data::CreditsStatusSlice creditsStatusSlice;
|
||||
PeerId premiumBotId = PeerId(0);
|
||||
bool canViewCurrencyMegagroupEarn = true;
|
||||
};
|
||||
|
||||
void setState(SavedState states);
|
||||
|
||||
Reference in New Issue
Block a user