From b45cd6e298778bb4c9569c06cfa6516398139f7a Mon Sep 17 00:00:00 2001 From: levlam Date: Tue, 6 Feb 2024 00:58:13 +0300 Subject: [PATCH] Add SavedMessagesManager::get_found_saved_messages_topic_object. --- td/telegram/SavedMessagesManager.cpp | 15 ++++++++++++--- td/telegram/SavedMessagesManager.h | 3 +++ 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/td/telegram/SavedMessagesManager.cpp b/td/telegram/SavedMessagesManager.cpp index e7a565283..c7a4681fa 100644 --- a/td/telegram/SavedMessagesManager.cpp +++ b/td/telegram/SavedMessagesManager.cpp @@ -533,9 +533,7 @@ void SavedMessagesManager::on_get_saved_messages_topics( } on_topic_changed(saved_messages_topic_id, topic); - found_saved_messages_topics.push_back(td_api::make_object( - saved_messages_topic_id.get_saved_messages_topic_object(td_), - td_->messages_manager_->get_message_object(full_message_id, "on_get_saved_messages_topics"))); + found_saved_messages_topics.push_back(get_found_saved_messages_topic_object(saved_messages_topic_id, topic)); } if (is_pinned) { @@ -552,6 +550,17 @@ void SavedMessagesManager::on_get_saved_messages_topics( total_count, std::move(found_saved_messages_topics), next_offset)); } +td_api::object_ptr SavedMessagesManager::get_found_saved_messages_topic_object( + SavedMessagesTopicId saved_messages_topic_id, const SavedMessagesTopic *topic) const { + td_api::object_ptr last_message_object; + if (topic->last_message_id_ != MessageId()) { + last_message_object = td_->messages_manager_->get_message_object( + {td_->dialog_manager_->get_my_dialog_id(), topic->last_message_id_}, "get_found_saved_messages_topic_object"); + } + return td_api::make_object( + saved_messages_topic_id.get_saved_messages_topic_object(td_), std::move(last_message_object)); +} + int64 SavedMessagesManager::get_next_pinned_saved_messages_topic_order() { current_pinned_saved_messages_topic_order_++; LOG(INFO) << "Assign pinned_order = " << current_pinned_saved_messages_topic_order_; diff --git a/td/telegram/SavedMessagesManager.h b/td/telegram/SavedMessagesManager.h index b168c25c0..0be495f42 100644 --- a/td/telegram/SavedMessagesManager.h +++ b/td/telegram/SavedMessagesManager.h @@ -92,6 +92,9 @@ class SavedMessagesManager final : public Actor { void on_topic_changed(SavedMessagesTopicId saved_messages_topic_id, SavedMessagesTopic *topic); + td_api::object_ptr get_found_saved_messages_topic_object( + SavedMessagesTopicId saved_messages_topic_id, const SavedMessagesTopic *topic) const; + Td *td_; ActorShared<> parent_;