Use last received message ID to adjust last_database_message_id, if there were no messages added.

This commit is contained in:
levlam 2021-07-14 21:49:35 +03:00
parent 69072e1a8f
commit 8f8e260521

View File

@ -22065,11 +22065,14 @@ void MessagesManager::on_get_history_from_database(DialogId dialog_id, MessageId
}
resolve_dependencies_force(td_, dependencies, "on_get_history_from_database");
if (from_the_end && !last_added_message_id.is_valid() && d->first_database_message_id.is_valid() &&
last_received_message_id <= d->first_database_message_id && !d->have_full_history) {
// failed to load from database a message from first_database_message_id to last_database_message_id; drop them
set_dialog_first_database_message_id(d, MessageId(), "on_get_history_from_database 8");
set_dialog_last_database_message_id(d, MessageId(), "on_get_history_from_database 9");
if (from_the_end && !last_added_message_id.is_valid() && d->first_database_message_id.is_valid() && !d->have_full_history) {
if (last_received_message_id <= d->first_database_message_id) {
// database definitely has no messages from first_database_message_id to last_database_message_id; drop them
set_dialog_first_database_message_id(d, MessageId(), "on_get_history_from_database 8");
set_dialog_last_database_message_id(d, MessageId(), "on_get_history_from_database 9");
} else {
set_dialog_last_database_message_id(d, last_received_message_id, "on_get_history_from_database 12");
}
}
if (!added_new_message && !only_local && dialog_id.get_type() != DialogType::SecretChat) {