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;
|
SliceBuilder sb;
|
||||||
for (auto &dialog_id : dialog_ids_) {
|
for (auto &dialog_id : dialog_ids_) {
|
||||||
sb << ',';
|
sb << ',';
|
||||||
if (!G()->parameters().use_message_db) {
|
if (!G()->parameters().use_chat_info_db) {
|
||||||
// if there is no dialog database, prefer to save dialogs by username
|
// if there is no dialog info database, prefer to save dialogs by username
|
||||||
string username;
|
string username;
|
||||||
switch (dialog_id.get_type()) {
|
switch (dialog_id.get_type()) {
|
||||||
case DialogType::User:
|
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;
|
break;
|
||||||
case DialogType::Chat:
|
case DialogType::Chat:
|
||||||
break;
|
break;
|
||||||
@ -104,20 +106,13 @@ void RecentDialogList::load_dialogs(Promise<Unit> &&promise) {
|
|||||||
dialog_ids.push_back(DialogId(to_integer<int64>(found_dialog)));
|
dialog_ids.push_back(DialogId(to_integer<int64>(found_dialog)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!dialog_ids.empty()) {
|
if (!dialog_ids.empty() && !G()->parameters().use_chat_info_db) {
|
||||||
if (G()->parameters().use_message_db) {
|
td_->messages_manager_->get_dialogs_from_list(
|
||||||
td_->messages_manager_->load_dialogs(
|
DialogListId(FolderId::main()), 102,
|
||||||
std::move(dialog_ids),
|
PromiseCreator::lambda([promise = mpas.get_promise()](td_api::object_ptr<td_api::chats> &&chats) mutable {
|
||||||
PromiseCreator::lambda(
|
promise.set_value(Unit());
|
||||||
[promise = mpas.get_promise()](vector<DialogId> dialog_ids) mutable { promise.set_value(Unit()); }));
|
}));
|
||||||
} else {
|
td_->contacts_manager_->search_contacts("", 1, mpas.get_promise());
|
||||||
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 {
|
|
||||||
promise.set_value(Unit());
|
|
||||||
}));
|
|
||||||
td_->contacts_manager_->search_contacts("", 1, mpas.get_promise());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
lock.set_value(Unit());
|
lock.set_value(Unit());
|
||||||
|
Loading…
Reference in New Issue
Block a user