From ddd2a223dd858e3657bdc1209dbe7e44b0128282 Mon Sep 17 00:00:00 2001 From: levlam Date: Sun, 26 Sep 2021 20:03:03 +0300 Subject: [PATCH] Prefer to save chats by ID if there is any database. --- td/telegram/RecentDialogList.cpp | 29 ++++++++++++----------------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/td/telegram/RecentDialogList.cpp b/td/telegram/RecentDialogList.cpp index 7d6b93740..23a7f5747 100644 --- a/td/telegram/RecentDialogList.cpp +++ b/td/telegram/RecentDialogList.cpp @@ -46,12 +46,14 @@ void RecentDialogList::save_dialogs() const { SliceBuilder sb; for (auto &dialog_id : dialog_ids_) { sb << ','; - if (!G()->parameters().use_message_db) { - // if there is no dialog database, prefer to save dialogs by username + if (!G()->parameters().use_chat_info_db) { + // if there is no dialog info database, prefer to save dialogs by username string username; switch (dialog_id.get_type()) { case DialogType::User: - username = td_->contacts_manager_->get_user_username(dialog_id.get_user_id()); + if (!td_->contacts_manager_->is_user_contact(dialog_id.get_user_id())) { + username = td_->contacts_manager_->get_user_username(dialog_id.get_user_id()); + } break; case DialogType::Chat: break; @@ -104,20 +106,13 @@ void RecentDialogList::load_dialogs(Promise &&promise) { dialog_ids.push_back(DialogId(to_integer(found_dialog))); } } - if (!dialog_ids.empty()) { - if (G()->parameters().use_message_db) { - td_->messages_manager_->load_dialogs( - std::move(dialog_ids), - PromiseCreator::lambda( - [promise = mpas.get_promise()](vector dialog_ids) mutable { promise.set_value(Unit()); })); - } else { - td_->messages_manager_->get_dialogs_from_list( - DialogListId(FolderId::main()), 102, - PromiseCreator::lambda([promise = mpas.get_promise()](td_api::object_ptr &&chats) mutable { - promise.set_value(Unit()); - })); - td_->contacts_manager_->search_contacts("", 1, mpas.get_promise()); - } + if (!dialog_ids.empty() && !G()->parameters().use_chat_info_db) { + td_->messages_manager_->get_dialogs_from_list( + DialogListId(FolderId::main()), 102, + PromiseCreator::lambda([promise = mpas.get_promise()](td_api::object_ptr &&chats) mutable { + promise.set_value(Unit()); + })); + td_->contacts_manager_->search_contacts("", 1, mpas.get_promise()); } lock.set_value(Unit());