mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-16 06:07:06 +02:00
Added initial API support for different boosts lists.
This commit is contained in:
parent
6fcf80c6cf
commit
79b5f7eda9
4 changed files with 23 additions and 13 deletions
|
@ -533,8 +533,13 @@ rpl::producer<rpl::no_value, QString> Boosts::request() {
|
|||
};
|
||||
_boostStatus.link = qs(data.vboost_url());
|
||||
|
||||
requestBoosts({}, [=](Data::BoostsListSlice &&slice) {
|
||||
_boostStatus.firstSlice = std::move(slice);
|
||||
using namespace Data;
|
||||
requestBoosts({ .gifts = false }, [=](BoostsListSlice &&slice) {
|
||||
_boostStatus.firstSliceBoosts = std::move(slice);
|
||||
requestBoosts({ .gifts = true }, [=](BoostsListSlice &&s) {
|
||||
_boostStatus.firstSliceGifts = std::move(s);
|
||||
consumer.put_done();
|
||||
});
|
||||
consumer.put_done();
|
||||
});
|
||||
}).fail([=](const MTP::Error &error) {
|
||||
|
@ -553,9 +558,11 @@ void Boosts::requestBoosts(
|
|||
}
|
||||
constexpr auto kTlFirstSlice = tl::make_int(kFirstSlice);
|
||||
constexpr auto kTlLimit = tl::make_int(kLimit);
|
||||
const auto gifts = token.gifts;
|
||||
_requestId = _api.request(MTPpremium_GetBoostsList(
|
||||
// MTP_flags(MTPpremium_GetBoostsList::Flag::f_gifts),
|
||||
MTP_flags(0),
|
||||
gifts
|
||||
? MTP_flags(MTPpremium_GetBoostsList::Flag::f_gifts)
|
||||
: MTP_flags(0),
|
||||
_peer->input,
|
||||
MTP_string(token.next),
|
||||
token.next.isEmpty() ? kTlFirstSlice : kTlLimit
|
||||
|
@ -596,12 +603,13 @@ void Boosts::requestBoosts(
|
|||
}
|
||||
done(Data::BoostsListSlice{
|
||||
.list = std::move(list),
|
||||
.total = data.vcount().v,
|
||||
.multipliedTotal = data.vcount().v,
|
||||
.allLoaded = (data.vcount().v == data.vboosts().v.size()),
|
||||
.token = Data::BoostsListSlice::OffsetToken{
|
||||
data.vnext_offset()
|
||||
.next = data.vnext_offset()
|
||||
? qs(*data.vnext_offset())
|
||||
: QString()
|
||||
: QString(),
|
||||
.gifts = gifts,
|
||||
},
|
||||
});
|
||||
}).fail([=] {
|
||||
|
|
|
@ -42,16 +42,18 @@ struct Boost final {
|
|||
struct BoostsListSlice final {
|
||||
struct OffsetToken final {
|
||||
QString next;
|
||||
bool gifts = false;
|
||||
};
|
||||
std::vector<Boost> list;
|
||||
int total = 0;
|
||||
int multipliedTotal = 0;
|
||||
bool allLoaded = false;
|
||||
OffsetToken token;
|
||||
};
|
||||
|
||||
struct BoostStatus final {
|
||||
BoostsOverview overview;
|
||||
BoostsListSlice firstSlice;
|
||||
BoostsListSlice firstSliceBoosts;
|
||||
BoostsListSlice firstSliceGifts;
|
||||
QString link;
|
||||
};
|
||||
|
||||
|
|
|
@ -271,7 +271,7 @@ void InnerWidget::fill() {
|
|||
::Settings::AddDivider(inner);
|
||||
::Settings::AddSkip(inner);
|
||||
|
||||
if (status.firstSlice.total > 0) {
|
||||
if (status.firstSliceBoosts.multipliedTotal > 0) {
|
||||
auto boostClicked = [=](const Data::Boost &boost) {
|
||||
if (!boost.giftCodeLink.slug.isEmpty()) {
|
||||
ResolveGiftCode(_controller, boost.giftCodeLink.slug);
|
||||
|
@ -294,10 +294,10 @@ void InnerWidget::fill() {
|
|||
header->setTitle(tr::lng_boosts_list_title(
|
||||
tr::now,
|
||||
lt_count,
|
||||
status.firstSlice.total));
|
||||
status.firstSliceBoosts.total));
|
||||
header->setSubTitle({});
|
||||
Statistics::AddBoostsList(
|
||||
status.firstSlice,
|
||||
status.firstSliceBoosts,
|
||||
inner,
|
||||
std::move(boostClicked),
|
||||
_peer,
|
||||
|
|
|
@ -757,7 +757,7 @@ void AddBoostsList(
|
|||
BoostCallback boostClickedCallback,
|
||||
not_null<PeerData*> peer,
|
||||
rpl::producer<QString> title) {
|
||||
const auto max = firstSlice.total;
|
||||
const auto max = firstSlice.multipliedTotal;
|
||||
struct State final {
|
||||
State(BoostsDescriptor d) : controller(std::move(d)) {
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue