Cancel previous update status queries.
GitOrigin-RevId: fcf23cf66267327faae001c69fa773cff84f4e88
This commit is contained in:
parent
6422e77e15
commit
7cb577dd6f
@ -375,8 +375,11 @@ class SetBotUpdatesStatusQuery : public Td::ResultHandler {
|
|||||||
|
|
||||||
class UpdateStatusQuery : public Td::ResultHandler {
|
class UpdateStatusQuery : public Td::ResultHandler {
|
||||||
public:
|
public:
|
||||||
void send(bool is_offline) {
|
NetQueryRef send(bool is_offline) {
|
||||||
send_query(G()->net_query_creator().create(create_storer(telegram_api::account_updateStatus(is_offline))));
|
auto net_query = G()->net_query_creator().create(create_storer(telegram_api::account_updateStatus(is_offline)));
|
||||||
|
auto result = net_query.get_weak();
|
||||||
|
send_query(std::move(net_query));
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void on_result(uint64 id, BufferSlice packet) override {
|
void on_result(uint64 id, BufferSlice packet) override {
|
||||||
@ -390,7 +393,9 @@ class UpdateStatusQuery : public Td::ResultHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void on_error(uint64 id, Status status) override {
|
void on_error(uint64 id, Status status) override {
|
||||||
LOG(ERROR) << "Receive error for UpdateStatusQuery: " << status;
|
if (status.code() != NetQuery::Cancelled) {
|
||||||
|
LOG(ERROR) << "Receive error for UpdateStatusQuery: " << status;
|
||||||
|
}
|
||||||
status.ignore();
|
status.ignore();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -3820,7 +3825,11 @@ void Td::on_online_updated(bool force, bool send_update) {
|
|||||||
}
|
}
|
||||||
if (force || is_online_) {
|
if (force || is_online_) {
|
||||||
contacts_manager_->set_my_online_status(is_online_, send_update);
|
contacts_manager_->set_my_online_status(is_online_, send_update);
|
||||||
create_handler<UpdateStatusQuery>()->send(!is_online_);
|
if (!update_status_query_.empty()) {
|
||||||
|
LOG(INFO) << "Cancel previous update status query";
|
||||||
|
cancel_query(update_status_query_);
|
||||||
|
}
|
||||||
|
update_status_query_ = create_handler<UpdateStatusQuery>()->send(!is_online_);
|
||||||
}
|
}
|
||||||
if (is_online_) {
|
if (is_online_) {
|
||||||
alarm_timeout_.set_timeout_in(ONLINE_ALARM_ID, ONLINE_TIMEOUT);
|
alarm_timeout_.set_timeout_in(ONLINE_ALARM_ID, ONLINE_TIMEOUT);
|
||||||
|
@ -235,6 +235,7 @@ class Td final : public NetQueryCallback {
|
|||||||
Container<ActorOwn<Actor>> request_actors_;
|
Container<ActorOwn<Actor>> request_actors_;
|
||||||
|
|
||||||
bool is_online_ = false;
|
bool is_online_ = false;
|
||||||
|
NetQueryRef update_status_query_;
|
||||||
|
|
||||||
int64 alarm_id_ = 1;
|
int64 alarm_id_ = 1;
|
||||||
std::unordered_map<int64, uint64> pending_alarms_;
|
std::unordered_map<int64, uint64> pending_alarms_;
|
||||||
|
Reference in New Issue
Block a user