diff --git a/td/telegram/SavedMessagesManager.cpp b/td/telegram/SavedMessagesManager.cpp index 186dac6d6..e6af3ad1d 100644 --- a/td/telegram/SavedMessagesManager.cpp +++ b/td/telegram/SavedMessagesManager.cpp @@ -447,8 +447,23 @@ void SavedMessagesManager::on_get_pinned_saved_dialogs(Result &&result) { } void SavedMessagesManager::get_saved_dialogs(int32 limit, Promise &&promise) { - td_->create_handler(std::move(promise)) - ->send(topic_list_.offset_date_, topic_list_.offset_message_id_, topic_list_.offset_dialog_id_, limit); + topic_list_.load_queries_.push_back(std::move(promise)); + if (topic_list_.load_queries_.size() == 1) { + auto query_promise = PromiseCreator::lambda([actor_id = actor_id(this)](Result &&result) { + send_closure(actor_id, &SavedMessagesManager::on_get_saved_dialogs, std::move(result)); + }); + td_->create_handler(std::move(query_promise)) + ->send(topic_list_.offset_date_, topic_list_.offset_message_id_, topic_list_.offset_dialog_id_, limit); + } +} + +void SavedMessagesManager::on_get_saved_dialogs(Result &&result) { + G()->ignore_result_if_closing(result); + if (result.is_error()) { + fail_promises(topic_list_.load_queries_, result.move_as_error()); + } else { + set_promises(topic_list_.load_queries_); + } } void SavedMessagesManager::on_get_saved_messages_topics( diff --git a/td/telegram/SavedMessagesManager.h b/td/telegram/SavedMessagesManager.h index 3b7cdd530..2b9d1bc65 100644 --- a/td/telegram/SavedMessagesManager.h +++ b/td/telegram/SavedMessagesManager.h @@ -110,6 +110,7 @@ class SavedMessagesManager final : public Actor { TopicDate last_topic_date_ = MIN_TOPIC_DATE; // in memory vector> load_pinned_queries_; + vector> load_queries_; int32 offset_date_ = std::numeric_limits::max(); DialogId offset_dialog_id_; @@ -128,6 +129,8 @@ class SavedMessagesManager final : public Actor { void get_saved_dialogs(int32 limit, Promise &&promise); + void on_get_saved_dialogs(Result &&result); + void on_get_saved_messages_topic_history(SavedMessagesTopicId saved_messages_topic_id, MessageId from_message_id, Result &&r_info, Promise> &&promise);