Cancel previous setEncryptedTyping query.

GitOrigin-RevId: dcebab6bae15c25def5f7c6bc15f03fffea66ef4
This commit is contained in:
levlam 2018-03-13 11:08:56 +03:00
parent 62e1f418e2
commit 86666a8418
3 changed files with 17 additions and 6 deletions

View File

@ -2786,6 +2786,10 @@ class SetTypingQuery : public Td::ResultHandler {
}
void on_error(uint64 id, Status status) override {
if (status.code() == NetQuery::Cancelled) {
return promise_.set_value(Unit());
}
LOG(INFO) << "Receive error for set typing: " << status;
td->messages_manager_->on_get_dialog_error(dialog_id_, status, "SetTypingQuery");
promise_.set_error(std::move(status));
@ -19166,7 +19170,6 @@ void MessagesManager::send_dialog_action(DialogId dialog_id, const tl_object_ptr
default:
UNREACHABLE();
}
// TODO cancel previous query
send_closure(G()->secret_chats_manager(), &SecretChatsManager::send_message_action, dialog_id.get_secret_chat_id(),
std::move(send_action));
promise.set_value(Unit());
@ -19229,7 +19232,7 @@ void MessagesManager::send_dialog_action(DialogId dialog_id, const tl_object_ptr
}
auto &query_ref = set_typing_query_[dialog_id];
if (!query_ref.empty()) {
if (!query_ref.empty() && !td_->auth_manager_->is_bot()) {
LOG(INFO) << "Cancel previous set typing query";
cancel_query(query_ref);
}

View File

@ -339,10 +339,16 @@ void SecretChatActor::send_message_action(tl_object_ptr<secret_api::SendMessageA
return;
}
bool flag = action->get_id() != secret_api::sendMessageCancelAction::ID;
context_->send_net_query(context_->net_query_creator().create(
auto net_query = context_->net_query_creator().create(
UniqueId::next(UniqueId::Type::Default, static_cast<uint8>(QueryType::Ignore)),
create_storer(telegram_api::messages_setEncryptedTyping(get_input_chat(), flag))),
actor_shared(this), false);
create_storer(telegram_api::messages_setEncryptedTyping(get_input_chat(), flag)));
if (!set_typing_query_.empty()) {
LOG(INFO) << "Cancel previous set typing query";
cancel_query(set_typing_query_);
}
set_typing_query_ = net_query.get_weak();
context_->send_net_query(std::move(net_query), actor_shared(this), false);
}
void SecretChatActor::send_read_history(int32 date, Promise<> promise) {
if (close_flag_) {

View File

@ -571,6 +571,8 @@ class SecretChatActor : public NetQueryCallback {
Container<OutboundMessageState> outbound_message_states_;
NetQueryRef set_typing_query_;
enum SendFlag {
None = 0,
External = 1,