Simplify RecentDialogList::removed_dialog_ids_ implementation.

This commit is contained in:
levlam 2024-01-04 19:10:15 +03:00
parent f43807ebbf
commit 2c6917d044
2 changed files with 5 additions and 6 deletions

View File

@ -141,7 +141,7 @@ void RecentDialogList::on_load_dialogs(vector<string> &&found_dialogs) {
} else {
dialog_id = DialogId(to_integer<int64>(*it));
}
if (dialog_id.is_valid() && removed_dialog_ids_.count(dialog_id) == 0 &&
if (dialog_id.is_valid() && td::contains(removed_dialog_ids_, dialog_id) == 0 &&
td_->dialog_manager_->have_dialog_info(dialog_id) &&
td_->dialog_manager_->have_input_peer(dialog_id, AccessRights::Read)) {
td_->dialog_manager_->force_create_dialog(dialog_id, "recent dialog");
@ -176,7 +176,7 @@ bool RecentDialogList::do_add_dialog(DialogId dialog_id) {
add_to_top(dialog_ids_, max_size_, dialog_id);
removed_dialog_ids_.erase(dialog_id);
td::remove(removed_dialog_ids_, dialog_id);
return true;
}
@ -189,8 +189,8 @@ void RecentDialogList::remove_dialog(DialogId dialog_id) {
}
if (td::remove(dialog_ids_, dialog_id)) {
save_dialogs();
} else if (!is_loaded_) {
removed_dialog_ids_.insert(dialog_id);
} else if (!is_loaded_ && !td::contains(removed_dialog_ids_, dialog_id)) {
removed_dialog_ids_.push_back(dialog_id);
}
}

View File

@ -11,7 +11,6 @@
#include "td/actor/actor.h"
#include "td/utils/common.h"
#include "td/utils/FlatHashSet.h"
#include "td/utils/Promise.h"
#include <utility>
@ -38,7 +37,7 @@ class RecentDialogList final : public Actor {
const char *name_;
size_t max_size_;
vector<DialogId> dialog_ids_;
FlatHashSet<DialogId, DialogIdHash> removed_dialog_ids_;
vector<DialogId> removed_dialog_ids_;
bool is_loaded_ = false;
vector<Promise<Unit>> load_list_queries_;