Improved concurrent API requests of async statistical charts.
This commit is contained in:
parent
c9c82446cb
commit
e9496fb612
|
@ -237,19 +237,30 @@ Statistics::GraphResult Statistics::requestZoom(
|
||||||
if (!channel) {
|
if (!channel) {
|
||||||
return lifetime;
|
return lifetime;
|
||||||
}
|
}
|
||||||
|
const auto wasEmpty = _zoomDeque.empty();
|
||||||
_api.request(MTPstats_LoadAsyncGraph(
|
_zoomDeque.push_back([=] {
|
||||||
MTP_flags(x
|
_api.request(MTPstats_LoadAsyncGraph(
|
||||||
? MTPstats_LoadAsyncGraph::Flag::f_x
|
MTP_flags(x
|
||||||
: MTPstats_LoadAsyncGraph::Flag(0)),
|
? MTPstats_LoadAsyncGraph::Flag::f_x
|
||||||
MTP_string(token),
|
: MTPstats_LoadAsyncGraph::Flag(0)),
|
||||||
MTP_long(x)
|
MTP_string(token),
|
||||||
)).done([=](const MTPStatsGraph &result) {
|
MTP_long(x)
|
||||||
consumer.put_next(StatisticalGraphFromTL(result));
|
)).done([=](const MTPStatsGraph &result) {
|
||||||
consumer.put_done();
|
consumer.put_next(StatisticalGraphFromTL(result));
|
||||||
}).fail([=](const MTP::Error &error) {
|
consumer.put_done();
|
||||||
consumer.put_error_copy(error.type());
|
if (!_zoomDeque.empty()) {
|
||||||
}).send();
|
_zoomDeque.pop_front();
|
||||||
|
if (!_zoomDeque.empty()) {
|
||||||
|
_zoomDeque.front()();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}).fail([=](const MTP::Error &error) {
|
||||||
|
consumer.put_error_copy(error.type());
|
||||||
|
}).send();
|
||||||
|
});
|
||||||
|
if (wasEmpty) {
|
||||||
|
_zoomDeque.front()();
|
||||||
|
}
|
||||||
|
|
||||||
return lifetime;
|
return lifetime;
|
||||||
};
|
};
|
||||||
|
|
|
@ -39,6 +39,8 @@ private:
|
||||||
Data::SupergroupStatistics _supergroupStats;
|
Data::SupergroupStatistics _supergroupStats;
|
||||||
MTP::Sender _api;
|
MTP::Sender _api;
|
||||||
|
|
||||||
|
std::deque<Fn<void()>> _zoomDeque;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class PublicForwards final {
|
class PublicForwards final {
|
||||||
|
|
Loading…
Reference in New Issue