From 58ae8cc5875f2556301cc0ad8699f3578bf89a40 Mon Sep 17 00:00:00 2001 From: levlam Date: Wed, 6 Jun 2018 17:01:01 +0300 Subject: [PATCH] Better condition for updating of last_database_message_id. GitOrigin-RevId: 48fce1e008339da955bece831b4f1ba9254e0263 --- td/telegram/MessagesManager.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/td/telegram/MessagesManager.cpp b/td/telegram/MessagesManager.cpp index cab84e61e..3120cefca 100644 --- a/td/telegram/MessagesManager.cpp +++ b/td/telegram/MessagesManager.cpp @@ -22666,7 +22666,10 @@ MessagesManager::Message *MessagesManager::add_message_to_dialog(Dialog *d, uniq *need_update_dialog_pos = true; } if (auto_attach && !message_id.is_yet_unsent() && message_id.get() >= d->last_new_message_id.get() && - (d->last_new_message_id.is_valid() || (message_id.is_local() && message_id.get() >= d->last_message_id.get()))) { + (d->last_new_message_id.is_valid() || + (message_id.is_local() && d->last_message_id.is_valid() && + (message_id.get() >= d->last_message_id.get() || + (d->last_database_message_id.is_valid() && message_id.get() > d->last_database_message_id.get()))))) { CHECK(message_id.get() <= d->last_message_id.get()); if (message_id.get() > d->last_database_message_id.get()) { set_dialog_last_database_message_id(d, message_id, "add_message_to_dialog");