Prevent extensive pinned message loading from the database.

GitOrigin-RevId: 4365b7bf0c95a89f616731a78017a2f4a15bd1d9
This commit is contained in:
levlam 2020-02-25 05:14:43 +03:00
parent f1d2d0751a
commit c407b244a0

View File

@ -26116,13 +26116,15 @@ MessagesManager::Message *MessagesManager::add_message_to_dialog(Dialog *d, uniq
// in get_message_notification_group_force
get_dialog_notification_group_id(d->dialog_id, get_notification_group_info(d, message.get()));
}
if (*need_update || (!d->last_new_message_id.is_valid() && !message_id.is_yet_unsent())) {
if (*need_update || (!d->last_new_message_id.is_valid() && !message_id.is_yet_unsent() && !message->from_database)) {
auto pinned_message_id = get_message_content_pinned_message_id(message->content.get());
if (pinned_message_id.is_valid() && have_message_force({dialog_id, pinned_message_id}, "preload pinned message")) {
if (pinned_message_id.is_valid() && pinned_message_id < message_id &&
have_message_force({dialog_id, pinned_message_id}, "preload pinned message")) {
LOG(INFO) << "Preloaded pinned " << pinned_message_id << " from database";
}
if (d->pinned_message_notification_message_id.is_valid() &&
d->pinned_message_notification_message_id < message_id &&
have_message_force({dialog_id, d->pinned_message_notification_message_id},
"preload previously pinned message")) {
LOG(INFO) << "Preloaded previously pinned " << d->pinned_message_notification_message_id << " from database";