Combine GetPinnedSavedDialogsQuery requests.

This commit is contained in:
levlam 2024-02-07 12:42:10 +03:00
parent 6cd6242931
commit 39ea60e889
2 changed files with 20 additions and 1 deletions

View File

@ -428,7 +428,22 @@ void SavedMessagesManager::load_saved_messages_topics(int32 limit, Promise<Unit>
}
void SavedMessagesManager::get_pinned_saved_dialogs(int32 limit, Promise<Unit> &&promise) {
td_->create_handler<GetPinnedSavedDialogsQuery>(std::move(promise))->send(limit);
topic_list_.load_pinned_queries_.push_back(std::move(promise));
if (topic_list_.load_pinned_queries_.size() == 1) {
auto query_promise = PromiseCreator::lambda([actor_id = actor_id(this)](Result<Unit> &&result) {
send_closure(actor_id, &SavedMessagesManager::on_get_pinned_saved_dialogs, std::move(result));
});
td_->create_handler<GetPinnedSavedDialogsQuery>(std::move(query_promise))->send(limit);
}
}
void SavedMessagesManager::on_get_pinned_saved_dialogs(Result<Unit> &&result) {
G()->ignore_result_if_closing(result);
if (result.is_error()) {
fail_promises(topic_list_.load_pinned_queries_, result.move_as_error());
} else {
set_promises(topic_list_.load_pinned_queries_);
}
}
void SavedMessagesManager::get_saved_dialogs(int32 limit, Promise<Unit> &&promise) {

View File

@ -109,6 +109,8 @@ class SavedMessagesManager final : public Actor {
TopicDate last_topic_date_ = MIN_TOPIC_DATE; // in memory
vector<Promise<Unit>> load_pinned_queries_;
int32 offset_date_ = std::numeric_limits<int32>::max();
DialogId offset_dialog_id_;
MessageId offset_message_id_;
@ -122,6 +124,8 @@ class SavedMessagesManager final : public Actor {
void get_pinned_saved_dialogs(int32 limit, Promise<Unit> &&promise);
void on_get_pinned_saved_dialogs(Result<Unit> &&result);
void get_saved_dialogs(int32 limit, Promise<Unit> &&promise);
void on_get_saved_messages_topic_history(SavedMessagesTopicId saved_messages_topic_id, MessageId from_message_id,