From 5ec3b9cfce1006e57f3f77630a2267671ba39849 Mon Sep 17 00:00:00 2001 From: levlam Date: Mon, 12 Apr 2021 05:11:06 +0300 Subject: [PATCH] Init MessagesManager on first call to get_dialog_force. --- td/telegram/MessagesManager.cpp | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/td/telegram/MessagesManager.cpp b/td/telegram/MessagesManager.cpp index 2f39d077d..9c6ba917e 100644 --- a/td/telegram/MessagesManager.cpp +++ b/td/telegram/MessagesManager.cpp @@ -27110,8 +27110,6 @@ NotificationGroupId MessagesManager::get_dialog_notification_group_id(DialogId d Result MessagesManager::get_message_push_notification_info( DialogId dialog_id, MessageId message_id, int64 random_id, UserId sender_user_id, DialogId sender_dialog_id, int32 date, bool is_from_scheduled, bool contains_mention, bool is_pinned, bool is_from_binlog) { - init(); - if (!is_from_scheduled && dialog_id == get_my_dialog_id()) { return Status::Error("Ignore notification in chat with self"); } @@ -27548,8 +27546,6 @@ vector MessagesManager::get_message_notification_group_key return {}; } - init(); - VLOG(notifications) << "Trying to load " << limit << " message notification groups from database from " << from_group_key; @@ -34637,9 +34633,7 @@ bool MessagesManager::set_dialog_order(Dialog *d, int64 new_order, bool need_sen } auto folder_ptr = get_dialog_folder(d->folder_id); - LOG_CHECK(folder_ptr != nullptr) << is_inited_ << ' ' << G()->close_flag() << ' ' << dialog_id << ' ' << d->folder_id - << ' ' << is_loaded_from_database << ' ' << td_->auth_manager_->is_authorized() - << ' ' << td_->auth_manager_->was_authorized() << ' ' << source; + CHECK(folder_ptr != nullptr); auto &folder = *folder_ptr; if (old_date == new_date) { if (new_order == DEFAULT_ORDER) { @@ -34986,7 +34980,8 @@ bool MessagesManager::have_dialog_force(DialogId dialog_id, const char *source) } MessagesManager::Dialog *MessagesManager::get_dialog_force(DialogId dialog_id, const char *source) { - // TODO remove most usages of that function, preload dialog asynchronously if possible + init(); + auto it = dialogs_.find(dialog_id); if (it != dialogs_.end()) { return it->second.get();