Use get_dialogs_from_list instead of get_dialogs.

This commit is contained in:
levlam 2021-08-12 15:16:13 +03:00
parent 307344da1c
commit d9aa50e1be

View File

@ -9179,12 +9179,8 @@ void MessagesManager::after_get_difference() {
if (!list->is_dialog_unread_count_inited_) { if (!list->is_dialog_unread_count_inited_) {
int32 limit = list->are_pinned_dialogs_inited_ ? static_cast<int32>(list->pinned_dialogs_.size()) int32 limit = list->are_pinned_dialogs_inited_ ? static_cast<int32>(list->pinned_dialogs_.size())
: get_pinned_dialogs_limit(dialog_list_id); : get_pinned_dialogs_limit(dialog_list_id);
get_dialogs(dialog_list_id, MIN_DIALOG_DATE, limit + 2, true, false, LOG(INFO) << "Loading chat list in " << dialog_list_id << " to init total unread count";
PromiseCreator::lambda([dialog_list_id](Result<Unit> result) { get_dialogs_from_list(dialog_list_id, limit + 2, Auto());
if (!G()->close_flag() && result.is_ok()) {
LOG(INFO) << "Inited total chat count in " << dialog_list_id;
}
}));
} }
} }
} }
@ -18336,8 +18332,7 @@ void MessagesManager::edit_dialog_filter(unique_ptr<DialogFilter> new_dialog_fil
if (old_list.need_unread_count_recalc_) { if (old_list.need_unread_count_recalc_) {
// repair unread count // repair unread count
get_dialogs(dialog_list_id, MIN_DIALOG_DATE, static_cast<int32>(old_list.pinned_dialogs_.size() + 2), true, get_dialogs_from_list(dialog_list_id, static_cast<int32>(old_list.pinned_dialogs_.size() + 2), Auto());
false, Promise<Unit>());
} }
for (auto &promise : load_list_promises) { for (auto &promise : load_list_promises) {
@ -29563,8 +29558,9 @@ void MessagesManager::on_update_pinned_dialogs(FolderId folder_id) {
return; return;
} }
// preload all pinned dialogs // preload all pinned dialogs
get_dialogs(DialogListId(folder_id), {SPONSORED_DIALOG_ORDER - 1, DialogId()}, int32 limit = narrow_cast<int32>(list->pinned_dialogs_.size()) +
narrow_cast<int32>(list->pinned_dialogs_.size()), true, true, Auto()); (folder_id == FolderId::main() && sponsored_dialog_id_.is_valid() ? 1 : 0);
get_dialogs_from_list(DialogListId(folder_id), limit, Auto());
reload_pinned_dialogs(DialogListId(folder_id), Auto()); reload_pinned_dialogs(DialogListId(folder_id), Auto());
} }
@ -37458,6 +37454,7 @@ bool MessagesManager::load_recently_found_dialogs(Promise<Unit> &promise) {
recently_found_dialogs_loaded_ = 1; recently_found_dialogs_loaded_ = 1;
resolve_recently_found_dialogs_multipromise_.set_ignore_errors(true); resolve_recently_found_dialogs_multipromise_.set_ignore_errors(true);
auto lock = resolve_recently_found_dialogs_multipromise_.get_promise();
for (auto &found_dialog : found_dialogs) { for (auto &found_dialog : found_dialogs) {
if (found_dialog[0] == '@') { if (found_dialog[0] == '@') {
@ -37474,12 +37471,15 @@ bool MessagesManager::load_recently_found_dialogs(Promise<Unit> &promise) {
get_dialog_force(dialog_id, "load_recently_found_dialogs"); get_dialog_force(dialog_id, "load_recently_found_dialogs");
} }
} }
resolve_recently_found_dialogs_multipromise_.get_promise().set_value(Unit());
} else { } else {
get_dialogs(DialogListId(FolderId::main()), MIN_DIALOG_DATE, MAX_GET_DIALOGS, false, false, get_dialogs_from_list(DialogListId(FolderId::main()), MAX_GET_DIALOGS + 2,
resolve_recently_found_dialogs_multipromise_.get_promise()); PromiseCreator::lambda(
[promise = resolve_recently_found_dialogs_multipromise_.get_promise()](
td_api::object_ptr<td_api::chats> &&chats) mutable { promise.set_value(Unit()); }));
td_->contacts_manager_->search_contacts("", 1, resolve_recently_found_dialogs_multipromise_.get_promise()); td_->contacts_manager_->search_contacts("", 1, resolve_recently_found_dialogs_multipromise_.get_promise());
} }
lock.set_value(Unit());
} }
return false; return false;
} }