mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Renamed Api::ChannelEarnStatistics with Api::EarnStatistics.
This commit is contained in:
parent
84055ed74e
commit
08fda055fc
4 changed files with 31 additions and 24 deletions
|
@ -99,8 +99,8 @@ public:
|
||||||
[[nodiscard]] Data::CreditsEarnStatistics data() const;
|
[[nodiscard]] Data::CreditsEarnStatistics data() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
const bool _isUser = false;
|
||||||
Data::CreditsEarnStatistics _data;
|
Data::CreditsEarnStatistics _data;
|
||||||
bool _isUser = false;
|
|
||||||
|
|
||||||
mtpRequestId _requestId = 0;
|
mtpRequestId _requestId = 0;
|
||||||
|
|
||||||
|
|
|
@ -14,6 +14,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "data/data_session.h"
|
#include "data/data_session.h"
|
||||||
#include "data/data_stories.h"
|
#include "data/data_stories.h"
|
||||||
#include "data/data_story.h"
|
#include "data/data_story.h"
|
||||||
|
#include "data/data_user.h"
|
||||||
#include "history/history.h"
|
#include "history/history.h"
|
||||||
#include "main/main_session.h"
|
#include "main/main_session.h"
|
||||||
|
|
||||||
|
@ -685,17 +686,18 @@ Data::BoostStatus Boosts::boostStatus() const {
|
||||||
return _boostStatus;
|
return _boostStatus;
|
||||||
}
|
}
|
||||||
|
|
||||||
ChannelEarnStatistics::ChannelEarnStatistics(not_null<ChannelData*> channel)
|
EarnStatistics::EarnStatistics(not_null<PeerData*> peer)
|
||||||
: StatisticsRequestSender(channel) {
|
: StatisticsRequestSender(peer)
|
||||||
|
, _isUser(peer->isUser()) {
|
||||||
}
|
}
|
||||||
|
|
||||||
rpl::producer<rpl::no_value, QString> ChannelEarnStatistics::request() {
|
rpl::producer<rpl::no_value, QString> EarnStatistics::request() {
|
||||||
return [=](auto consumer) {
|
return [=](auto consumer) {
|
||||||
auto lifetime = rpl::lifetime();
|
auto lifetime = rpl::lifetime();
|
||||||
|
|
||||||
makeRequest(MTPstats_GetBroadcastRevenueStats(
|
makeRequest(MTPstats_GetBroadcastRevenueStats(
|
||||||
MTP_flags(0),
|
MTP_flags(0),
|
||||||
channel()->input
|
(_isUser ? user()->input : channel()->input)
|
||||||
)).done([=](const MTPstats_BroadcastRevenueStats &result) {
|
)).done([=](const MTPstats_BroadcastRevenueStats &result) {
|
||||||
const auto &data = result.data();
|
const auto &data = result.data();
|
||||||
const auto &balances = data.vbalances().data();
|
const auto &balances = data.vbalances().data();
|
||||||
|
@ -712,18 +714,22 @@ rpl::producer<rpl::no_value, QString> ChannelEarnStatistics::request() {
|
||||||
requestHistory({}, [=](Data::EarnHistorySlice &&slice) {
|
requestHistory({}, [=](Data::EarnHistorySlice &&slice) {
|
||||||
_data.firstHistorySlice = std::move(slice);
|
_data.firstHistorySlice = std::move(slice);
|
||||||
|
|
||||||
api().request(
|
if (!_isUser) {
|
||||||
MTPchannels_GetFullChannel(channel()->inputChannel)
|
api().request(
|
||||||
).done([=](const MTPmessages_ChatFull &result) {
|
MTPchannels_GetFullChannel(channel()->inputChannel)
|
||||||
result.data().vfull_chat().match([&](
|
).done([=](const MTPmessages_ChatFull &result) {
|
||||||
const MTPDchannelFull &d) {
|
result.data().vfull_chat().match([&](
|
||||||
_data.switchedOff = d.is_restricted_sponsored();
|
const MTPDchannelFull &d) {
|
||||||
}, [](const auto &) {
|
_data.switchedOff = d.is_restricted_sponsored();
|
||||||
});
|
}, [](const auto &) {
|
||||||
|
});
|
||||||
|
consumer.put_done();
|
||||||
|
}).fail([=](const MTP::Error &error) {
|
||||||
|
consumer.put_error_copy(error.type());
|
||||||
|
}).send();
|
||||||
|
} else {
|
||||||
consumer.put_done();
|
consumer.put_done();
|
||||||
}).fail([=](const MTP::Error &error) {
|
}
|
||||||
consumer.put_error_copy(error.type());
|
|
||||||
}).send();
|
|
||||||
});
|
});
|
||||||
}).fail([=](const MTP::Error &error) {
|
}).fail([=](const MTP::Error &error) {
|
||||||
consumer.put_error_copy(error.type());
|
consumer.put_error_copy(error.type());
|
||||||
|
@ -733,7 +739,7 @@ rpl::producer<rpl::no_value, QString> ChannelEarnStatistics::request() {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChannelEarnStatistics::requestHistory(
|
void EarnStatistics::requestHistory(
|
||||||
const Data::EarnHistorySlice::OffsetToken &token,
|
const Data::EarnHistorySlice::OffsetToken &token,
|
||||||
Fn<void(Data::EarnHistorySlice)> done) {
|
Fn<void(Data::EarnHistorySlice)> done) {
|
||||||
if (_requestId) {
|
if (_requestId) {
|
||||||
|
@ -742,7 +748,7 @@ void ChannelEarnStatistics::requestHistory(
|
||||||
constexpr auto kTlFirstSlice = tl::make_int(kFirstSlice);
|
constexpr auto kTlFirstSlice = tl::make_int(kFirstSlice);
|
||||||
constexpr auto kTlLimit = tl::make_int(kLimit);
|
constexpr auto kTlLimit = tl::make_int(kLimit);
|
||||||
_requestId = api().request(MTPstats_GetBroadcastRevenueTransactions(
|
_requestId = api().request(MTPstats_GetBroadcastRevenueTransactions(
|
||||||
channel()->input,
|
(_isUser ? user()->input : channel()->input),
|
||||||
MTP_int(token),
|
MTP_int(token),
|
||||||
(!token) ? kTlFirstSlice : kTlLimit
|
(!token) ? kTlFirstSlice : kTlLimit
|
||||||
)).done([=](const MTPstats_BroadcastRevenueTransactions &result) {
|
)).done([=](const MTPstats_BroadcastRevenueTransactions &result) {
|
||||||
|
@ -803,7 +809,7 @@ void ChannelEarnStatistics::requestHistory(
|
||||||
}).send();
|
}).send();
|
||||||
}
|
}
|
||||||
|
|
||||||
Data::EarnStatistics ChannelEarnStatistics::data() const {
|
Data::EarnStatistics EarnStatistics::data() const {
|
||||||
return _data;
|
return _data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -79,9 +79,9 @@ private:
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class ChannelEarnStatistics final : public StatisticsRequestSender {
|
class EarnStatistics final : public StatisticsRequestSender {
|
||||||
public:
|
public:
|
||||||
explicit ChannelEarnStatistics(not_null<ChannelData*> channel);
|
explicit EarnStatistics(not_null<PeerData*> peer);
|
||||||
|
|
||||||
[[nodiscard]] rpl::producer<rpl::no_value, QString> request();
|
[[nodiscard]] rpl::producer<rpl::no_value, QString> request();
|
||||||
void requestHistory(
|
void requestHistory(
|
||||||
|
@ -94,6 +94,7 @@ public:
|
||||||
static constexpr auto kLimit = int(10);
|
static constexpr auto kLimit = int(10);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
const bool _isUser = false;
|
||||||
Data::EarnStatistics _data;
|
Data::EarnStatistics _data;
|
||||||
|
|
||||||
mtpRequestId _requestId = 0;
|
mtpRequestId _requestId = 0;
|
||||||
|
|
|
@ -269,11 +269,11 @@ InnerWidget::InnerWidget(
|
||||||
void InnerWidget::load() {
|
void InnerWidget::load() {
|
||||||
struct State final {
|
struct State final {
|
||||||
State(not_null<PeerData*> peer)
|
State(not_null<PeerData*> peer)
|
||||||
: api(peer->asChannel())
|
: api(peer)
|
||||||
, apiCredits(peer)
|
, apiCredits(peer)
|
||||||
, apiCreditsHistory(peer, true, true) {
|
, apiCreditsHistory(peer, true, true) {
|
||||||
}
|
}
|
||||||
Api::ChannelEarnStatistics api;
|
Api::EarnStatistics api;
|
||||||
Api::CreditsEarnStatistics apiCredits;
|
Api::CreditsEarnStatistics apiCredits;
|
||||||
Api::CreditsHistory apiCreditsHistory;
|
Api::CreditsHistory apiCreditsHistory;
|
||||||
rpl::lifetime apiLifetime;
|
rpl::lifetime apiLifetime;
|
||||||
|
@ -1375,7 +1375,7 @@ void InnerWidget::fill() {
|
||||||
ShowMoreState(not_null<ChannelData*> channel)
|
ShowMoreState(not_null<ChannelData*> channel)
|
||||||
: api(channel) {
|
: api(channel) {
|
||||||
}
|
}
|
||||||
Api::ChannelEarnStatistics api;
|
Api::EarnStatistics api;
|
||||||
bool loading = false;
|
bool loading = false;
|
||||||
Data::EarnHistorySlice::OffsetToken token;
|
Data::EarnHistorySlice::OffsetToken token;
|
||||||
rpl::variable<int> showed = 0;
|
rpl::variable<int> showed = 0;
|
||||||
|
|
Loading…
Add table
Reference in a new issue