From 37cab6d1fc0b77eef21750248c98a1f00b50c66a Mon Sep 17 00:00:00 2001 From: levlam Date: Wed, 8 Jan 2020 04:34:15 +0300 Subject: [PATCH] Do not unload last edited message in the chat. GitOrigin-RevId: d8a5f8053f8d0ef6bd86f503a456f6631a5f9d9e --- td/telegram/MessagesManager.cpp | 6 +++++- td/telegram/MessagesManager.h | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/td/telegram/MessagesManager.cpp b/td/telegram/MessagesManager.cpp index 4b52237e..8d778b75 100644 --- a/td/telegram/MessagesManager.cpp +++ b/td/telegram/MessagesManager.cpp @@ -6379,6 +6379,7 @@ void MessagesManager::on_message_edited(FullMessageId full_message_id) { const Message *m = get_message(d, full_message_id.get_message_id()); CHECK(m != nullptr); if (td_->auth_manager_->is_bot()) { + d->last_edited_message_id = m->message_id; send_update_message_edited(dialog_id, m); } update_used_hashtags(dialog_id, m); @@ -12318,6 +12319,7 @@ bool MessagesManager::can_unload_message(const Dialog *d, const Message *m) cons // don't want to unload messages with pending web pages // don't want to unload message with active reply markup // don't want to unload pinned message + // don't want to unload last edited message, because server can send updateEditChannelMessage again // can't unload from memory last dialog, last database messages, yet unsent messages, being edited media messages and active live locations // can't unload messages in dialog with active suffix load query FullMessageId full_message_id{d->dialog_id, m->message_id}; @@ -12325,7 +12327,8 @@ bool MessagesManager::can_unload_message(const Dialog *d, const Message *m) cons !m->message_id.is_yet_unsent() && active_live_location_full_message_ids_.count(full_message_id) == 0 && replied_by_yet_unsent_messages_.count(full_message_id) == 0 && m->edited_content == nullptr && waiting_for_web_page_messages_.count(full_message_id) == 0 && d->suffix_load_queries_.empty() && - m->message_id != d->reply_markup_message_id && m->message_id != d->pinned_message_id; + m->message_id != d->reply_markup_message_id && m->message_id != d->pinned_message_id && + m->message_id != d->last_edited_message_id; } void MessagesManager::unload_message(Dialog *d, MessageId message_id) { @@ -27239,6 +27242,7 @@ bool MessagesManager::update_message(Dialog *d, Message *old_message, unique_ptr } if (is_edited && !td_->auth_manager_->is_bot()) { + d->last_edited_message_id = message_id; send_update_message_edited(dialog_id, old_message); } diff --git a/td/telegram/MessagesManager.h b/td/telegram/MessagesManager.h index 0df8a8b1..7dd93475 100644 --- a/td/telegram/MessagesManager.h +++ b/td/telegram/MessagesManager.h @@ -1060,6 +1060,7 @@ class MessagesManager : public Actor { int32 pending_last_message_date = 0; MessageId pending_last_message_id; MessageId max_notification_message_id; + MessageId last_edited_message_id; uint32 scheduled_messages_sync_generation = 0; MessageId max_added_message_id;