From 73f3696edab4cbf42af74060b2be66384c8668f5 Mon Sep 17 00:00:00 2001 From: levlam Date: Tue, 6 Feb 2024 16:08:41 +0300 Subject: [PATCH] Send updateSavedMessagesTopic when last topic message changes. --- td/telegram/MessagesManager.cpp | 3 +++ td/telegram/SavedMessagesManager.cpp | 10 ++++++++++ td/telegram/SavedMessagesManager.h | 2 ++ 3 files changed, 15 insertions(+) diff --git a/td/telegram/MessagesManager.cpp b/td/telegram/MessagesManager.cpp index 1be88d03c..c1d04c009 100644 --- a/td/telegram/MessagesManager.cpp +++ b/td/telegram/MessagesManager.cpp @@ -28489,6 +28489,9 @@ void MessagesManager::send_update_last_message_if_needed(const Dialog *d, const if (m->message_id == d->last_message_id) { send_update_chat_last_message_impl(d, source); } + if (d->dialog_id == td_->dialog_manager_->get_my_dialog_id() && m->saved_messages_topic_id.is_valid()) { + td_->saved_messages_manager_->on_topic_message_updated(m->saved_messages_topic_id, m->message_id); + } } void MessagesManager::send_update_chat_last_message(Dialog *d, const char *source) { diff --git a/td/telegram/SavedMessagesManager.cpp b/td/telegram/SavedMessagesManager.cpp index 4f57e1dc4..e05e4bfcd 100644 --- a/td/telegram/SavedMessagesManager.cpp +++ b/td/telegram/SavedMessagesManager.cpp @@ -353,6 +353,16 @@ void SavedMessagesManager::do_set_topic_last_message_id(SavedMessagesTopic *topi topic->is_changed_ = true; } +void SavedMessagesManager::on_topic_message_updated(SavedMessagesTopicId saved_messages_topic_id, + MessageId message_id) { + auto *topic = get_topic(saved_messages_topic_id); + if (topic == nullptr || topic->last_message_id_ != message_id) { + return; + } + + send_update_saved_messages_topic(topic); +} + void SavedMessagesManager::on_topic_message_deleted(SavedMessagesTopicId saved_messages_topic_id, MessageId message_id) { auto *topic = get_topic(saved_messages_topic_id); diff --git a/td/telegram/SavedMessagesManager.h b/td/telegram/SavedMessagesManager.h index fec567e03..e04b88e96 100644 --- a/td/telegram/SavedMessagesManager.h +++ b/td/telegram/SavedMessagesManager.h @@ -29,6 +29,8 @@ class SavedMessagesManager final : public Actor { void set_topic_last_message_id(SavedMessagesTopicId saved_messages_topic_id, MessageId last_message_id, int32 last_message_date); + void on_topic_message_updated(SavedMessagesTopicId saved_messages_topic_id, MessageId message_id); + void on_topic_message_deleted(SavedMessagesTopicId saved_messages_topic_id, MessageId message_id); void get_pinned_saved_messages_topics(Promise> &&promise);