mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-08 08:04:08 +02:00
Improved concurrent API requests of async statistical charts.
This commit is contained in:
parent
c9c82446cb
commit
e9496fb612
2 changed files with 26 additions and 13 deletions
|
@ -237,7 +237,8 @@ Statistics::GraphResult Statistics::requestZoom(
|
||||||
if (!channel) {
|
if (!channel) {
|
||||||
return lifetime;
|
return lifetime;
|
||||||
}
|
}
|
||||||
|
const auto wasEmpty = _zoomDeque.empty();
|
||||||
|
_zoomDeque.push_back([=] {
|
||||||
_api.request(MTPstats_LoadAsyncGraph(
|
_api.request(MTPstats_LoadAsyncGraph(
|
||||||
MTP_flags(x
|
MTP_flags(x
|
||||||
? MTPstats_LoadAsyncGraph::Flag::f_x
|
? MTPstats_LoadAsyncGraph::Flag::f_x
|
||||||
|
@ -247,9 +248,19 @@ Statistics::GraphResult Statistics::requestZoom(
|
||||||
)).done([=](const MTPStatsGraph &result) {
|
)).done([=](const MTPStatsGraph &result) {
|
||||||
consumer.put_next(StatisticalGraphFromTL(result));
|
consumer.put_next(StatisticalGraphFromTL(result));
|
||||||
consumer.put_done();
|
consumer.put_done();
|
||||||
|
if (!_zoomDeque.empty()) {
|
||||||
|
_zoomDeque.pop_front();
|
||||||
|
if (!_zoomDeque.empty()) {
|
||||||
|
_zoomDeque.front()();
|
||||||
|
}
|
||||||
|
}
|
||||||
}).fail([=](const MTP::Error &error) {
|
}).fail([=](const MTP::Error &error) {
|
||||||
consumer.put_error_copy(error.type());
|
consumer.put_error_copy(error.type());
|
||||||
}).send();
|
}).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…
Add table
Reference in a new issue