Optimize database_message_id updating in on_get_history.
This commit is contained in:
parent
6729581d03
commit
9c961b2eb8
@ -8903,7 +8903,6 @@ void MessagesManager::on_get_history(DialogId dialog_id, MessageId from_message_
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (need_update_database_message_ids) {
|
if (need_update_database_message_ids) {
|
||||||
bool is_dialog_updated = false;
|
|
||||||
if (!d->last_database_message_id.is_valid()) {
|
if (!d->last_database_message_id.is_valid()) {
|
||||||
CHECK(d->last_message_id.is_valid());
|
CHECK(d->last_message_id.is_valid());
|
||||||
MessagesConstIterator it(d, d->last_message_id);
|
MessagesConstIterator it(d, d->last_message_id);
|
||||||
@ -8918,7 +8917,6 @@ void MessagesManager::on_get_history(DialogId dialog_id, MessageId from_message_
|
|||||||
}
|
}
|
||||||
--it;
|
--it;
|
||||||
}
|
}
|
||||||
is_dialog_updated = true;
|
|
||||||
} else {
|
} else {
|
||||||
LOG_CHECK(d->last_new_message_id.is_valid())
|
LOG_CHECK(d->last_new_message_id.is_valid())
|
||||||
<< dialog_id << " " << from_the_end << " " << d->first_database_message_id << " "
|
<< dialog_id << " " << from_the_end << " " << d->first_database_message_id << " "
|
||||||
@ -8933,28 +8931,34 @@ void MessagesManager::on_get_history(DialogId dialog_id, MessageId from_message_
|
|||||||
{
|
{
|
||||||
MessagesConstIterator it(d, d->first_database_message_id);
|
MessagesConstIterator it(d, d->first_database_message_id);
|
||||||
if (*it != nullptr && ((*it)->message_id == d->first_database_message_id || (*it)->have_next)) {
|
if (*it != nullptr && ((*it)->message_id == d->first_database_message_id || (*it)->have_next)) {
|
||||||
|
MessageId new_first_database_message_id = d->first_database_message_id;
|
||||||
while (*it != nullptr) {
|
while (*it != nullptr) {
|
||||||
auto message_id = (*it)->message_id;
|
auto message_id = (*it)->message_id;
|
||||||
if ((message_id.is_server() || message_id.is_local()) && message_id < d->first_database_message_id) {
|
if ((message_id.is_server() || message_id.is_local()) && message_id < new_first_database_message_id) {
|
||||||
set_dialog_first_database_message_id(d, message_id, "on_get_history 2");
|
new_first_database_message_id = message_id;
|
||||||
try_restore_dialog_reply_markup(d, *it);
|
try_restore_dialog_reply_markup(d, *it);
|
||||||
is_dialog_updated = true;
|
|
||||||
}
|
}
|
||||||
--it;
|
--it;
|
||||||
}
|
}
|
||||||
|
if (new_first_database_message_id != d->first_database_message_id) {
|
||||||
|
set_dialog_first_database_message_id(d, new_first_database_message_id, "on_get_history 2");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
MessagesConstIterator it(d, d->last_database_message_id);
|
MessagesConstIterator it(d, d->last_database_message_id);
|
||||||
if (*it != nullptr && ((*it)->message_id == d->last_database_message_id || (*it)->have_next)) {
|
if (*it != nullptr && ((*it)->message_id == d->last_database_message_id || (*it)->have_next)) {
|
||||||
|
MessageId new_last_database_message_id = d->last_database_message_id;
|
||||||
while (*it != nullptr) {
|
while (*it != nullptr) {
|
||||||
auto message_id = (*it)->message_id;
|
auto message_id = (*it)->message_id;
|
||||||
if ((message_id.is_server() || message_id.is_local()) && message_id > d->last_database_message_id) {
|
if ((message_id.is_server() || message_id.is_local()) && message_id > new_last_database_message_id) {
|
||||||
set_dialog_last_database_message_id(d, message_id, "on_get_history 2");
|
new_last_database_message_id = message_id;
|
||||||
is_dialog_updated = true;
|
|
||||||
}
|
}
|
||||||
++it;
|
++it;
|
||||||
}
|
}
|
||||||
|
if (new_last_database_message_id != d->last_database_message_id) {
|
||||||
|
set_dialog_last_database_message_id(d, new_last_database_message_id, "on_get_history 2");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -8974,10 +8978,6 @@ void MessagesManager::on_get_history(DialogId dialog_id, MessageId from_message_
|
|||||||
first_message_id = first_added_message_id;
|
first_message_id = first_added_message_id;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_dialog_updated) {
|
|
||||||
on_dialog_updated(dialog_id, "on_get_history");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user