Update message_count_by_index even there is no message database.

This commit is contained in:
levlam 2021-10-03 15:12:56 +03:00
parent 11af0a058d
commit b6d9252279

View File

@ -9734,7 +9734,6 @@ void MessagesManager::on_get_dialog_messages_search_result(DialogId dialog_id, c
bool from_the_end = !from_message_id.is_valid() || bool from_the_end = !from_message_id.is_valid() ||
(d->last_message_id != MessageId() && from_message_id > d->last_message_id) || (d->last_message_id != MessageId() && from_message_id > d->last_message_id) ||
from_message_id >= MessageId::max(); from_message_id >= MessageId::max();
if (G()->parameters().use_message_db) {
bool update_dialog = false; bool update_dialog = false;
auto &old_message_count = d->message_count_by_index[message_search_filter_index(filter)]; auto &old_message_count = d->message_count_by_index[message_search_filter_index(filter)];
@ -9748,16 +9747,16 @@ void MessagesManager::on_get_dialog_messages_search_result(DialogId dialog_id, c
update_dialog = true; update_dialog = true;
} }
auto &old_first_db_message_id = d->first_database_message_id_by_index[message_search_filter_index(filter)]; auto &old_first_database_message_id = d->first_database_message_id_by_index[message_search_filter_index(filter)];
if ((from_the_end || (old_first_db_message_id.is_valid() && old_first_db_message_id <= from_message_id)) && if ((from_the_end ||
(!old_first_db_message_id.is_valid() || first_added_message_id < old_first_db_message_id)) { (old_first_database_message_id.is_valid() && old_first_database_message_id <= from_message_id)) &&
old_first_db_message_id = first_added_message_id; (!old_first_database_message_id.is_valid() || first_added_message_id < old_first_database_message_id)) {
old_first_database_message_id = first_added_message_id;
update_dialog = true; update_dialog = true;
} }
if (update_dialog) { if (update_dialog) {
on_dialog_updated(dialog_id, "search results"); on_dialog_updated(dialog_id, "search results");
} }
}
if (from_the_end && filter == MessageSearchFilter::Pinned) { if (from_the_end && filter == MessageSearchFilter::Pinned) {
set_dialog_last_pinned_message_id(d, result.empty() ? MessageId() : result[0]); set_dialog_last_pinned_message_id(d, result.empty() ? MessageId() : result[0]);
@ -9801,9 +9800,9 @@ void MessagesManager::on_get_dialog_message_count(DialogId dialog_id, MessageSea
} }
if (total_count == 0) { if (total_count == 0) {
auto &old_first_db_message_id = d->first_database_message_id_by_index[message_search_filter_index(filter)]; auto &old_first_database_message_id = d->first_database_message_id_by_index[message_search_filter_index(filter)];
if (old_first_db_message_id != MessageId::min()) { if (old_first_database_message_id != MessageId::min()) {
old_first_db_message_id = MessageId::min(); old_first_database_message_id = MessageId::min();
on_dialog_updated(dialog_id, "on_get_dialog_message_count"); on_dialog_updated(dialog_id, "on_get_dialog_message_count");
} }
if (filter == MessageSearchFilter::Pinned) { if (filter == MessageSearchFilter::Pinned) {