From 13e8094aaacdcf2f6224035c40ae3a0659932a27 Mon Sep 17 00:00:00 2001 From: levlam Date: Fri, 13 Jan 2023 14:38:36 +0300 Subject: [PATCH] Reload contacts if failed to load the from database. --- td/telegram/ContactsManager.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/td/telegram/ContactsManager.cpp b/td/telegram/ContactsManager.cpp index 4ae23247e..59bf825a7 100644 --- a/td/telegram/ContactsManager.cpp +++ b/td/telegram/ContactsManager.cpp @@ -6048,7 +6048,8 @@ int64 ContactsManager::get_contacts_hash() { } void ContactsManager::reload_contacts(bool force) { - if (!td_->auth_manager_->is_bot() && next_contacts_sync_date_ != std::numeric_limits::max() && + if (!G()->close_flag() && !td_->auth_manager_->is_bot() && + next_contacts_sync_date_ != std::numeric_limits::max() && (next_contacts_sync_date_ < G()->unix_time() || force)) { next_contacts_sync_date_ = std::numeric_limits::max(); td_->create_handler()->send(get_contacts_hash()); @@ -9542,6 +9543,9 @@ void ContactsManager::on_load_contacts_from_database(string value) { [actor_id = actor_id(this), expected_contact_count = user_ids.size()](Result result) { if (result.is_ok()) { send_closure(actor_id, &ContactsManager::on_get_contacts_finished, expected_contact_count); + } else { + LOG(INFO) << "Failed to load contact users from database: " << result.error(); + send_closure(actor_id, &ContactsManager::reload_contacts, true); } }));