From c07bc54f34c317a824121bdeb2208b5a464d2f14 Mon Sep 17 00:00:00 2001 From: levlam Date: Wed, 27 Jun 2018 18:28:58 +0300 Subject: [PATCH] Fix suffix_load_first_message_id when corresponding message is deleted. GitOrigin-RevId: 025744f5120f7f6860f0af46dfcdc8870110f48a --- td/telegram/MessagesManager.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/td/telegram/MessagesManager.cpp b/td/telegram/MessagesManager.cpp index b557dff64..18695c160 100644 --- a/td/telegram/MessagesManager.cpp +++ b/td/telegram/MessagesManager.cpp @@ -11410,6 +11410,25 @@ unique_ptr MessagesManager::do_delete_message(Dialog * } else { set_dialog_first_database_message_id(d, MessageId(), "do_delete_message"); } + + if (message_id == d->suffix_load_first_message_id_) { + MessagesConstIterator it(d, message_id); + CHECK(*it == m); + if ((*it)->have_previous) { + --it; + if (*it != nullptr) { + d->suffix_load_first_message_id_ = (*it)->message_id; + } else { + LOG(ERROR) << "have_previous is true, but there is no previous for " << full_message_id << " from " << source; + dump_debug_message_op(d); + d->suffix_load_first_message_id_ = MessageId(); + d->suffix_load_done_ = false; + } + } else { + d->suffix_load_first_message_id_ = MessageId(); + d->suffix_load_done_ = false; + } + } } if (only_from_memory && message_id.get() >= d->suffix_load_first_message_id_.get()) { d->suffix_load_first_message_id_ = MessageId();