Prefer to save chats by ID if there is any database.
This commit is contained in:
parent
c5a2e9a870
commit
ddd2a223dd
@ -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:
|
||||
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,13 +106,7 @@ void RecentDialogList::load_dialogs(Promise<Unit> &&promise) {
|
||||
dialog_ids.push_back(DialogId(to_integer<int64>(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<DialogId> dialog_ids) mutable { promise.set_value(Unit()); }));
|
||||
} else {
|
||||
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<td_api::chats> &&chats) mutable {
|
||||
@ -118,7 +114,6 @@ void RecentDialogList::load_dialogs(Promise<Unit> &&promise) {
|
||||
}));
|
||||
td_->contacts_manager_->search_contacts("", 1, mpas.get_promise());
|
||||
}
|
||||
}
|
||||
|
||||
lock.set_value(Unit());
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user