From bc8811ea82b7924fbd2856892e028f60228ac4d8 Mon Sep 17 00:00:00 2001 From: levlam Date: Mon, 20 Feb 2023 12:40:49 +0300 Subject: [PATCH] Simplify MessagesManager::can_unload_message for bots; allow to unload the last message. --- td/telegram/MessagesManager.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/td/telegram/MessagesManager.cpp b/td/telegram/MessagesManager.cpp index 224281761..91c72c0bc 100644 --- a/td/telegram/MessagesManager.cpp +++ b/td/telegram/MessagesManager.cpp @@ -16335,6 +16335,12 @@ bool MessagesManager::can_unload_message(const Dialog *d, const Message *m) cons CHECK(d != nullptr); CHECK(m != nullptr); CHECK(m->message_id.is_valid()); + FullMessageId full_message_id{d->dialog_id, m->message_id}; + if (td_->auth_manager_->is_bot() && !G()->parameters().use_file_db) { + return !m->message_id.is_yet_unsent() && replied_by_yet_unsent_messages_.count(full_message_id) == 0 && + m->edited_content == nullptr && m->message_id != d->last_pinned_message_id && + m->message_id != d->last_edited_message_id; + } // don't want to unload messages from opened dialogs // don't want to unload messages to which there are replies in yet unsent messages // don't want to unload message with active reply markup @@ -16343,7 +16349,6 @@ bool MessagesManager::can_unload_message(const Dialog *d, const Message *m) cons // don't want to unload messages from the last album // 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}; return !d->is_opened && m->message_id != d->last_message_id && m->message_id != d->last_database_message_id && !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 &&