Add DialogList.in_memory_total_count_.

GitOrigin-RevId: ab418de72778dc9a51761a5acbcf1fadc2116197
This commit is contained in:
levlam 2019-12-26 05:21:09 +03:00
parent 97ab18945f
commit 03311836af
2 changed files with 12 additions and 3 deletions

View File

@ -9584,7 +9584,7 @@ void MessagesManager::recalc_unread_count(FolderId folder_id) {
int32 dialog_muted_count = 0; int32 dialog_muted_count = 0;
int32 dialog_marked_count = 0; int32 dialog_marked_count = 0;
int32 dialog_muted_marked_count = 0; int32 dialog_muted_marked_count = 0;
for (auto &dialog_date : list.ordered_server_dialogs_) { for (const auto &dialog_date : list.ordered_server_dialogs_) {
auto dialog_id = dialog_date.get_dialog_id(); auto dialog_id = dialog_date.get_dialog_id();
Dialog *d = get_dialog(dialog_id); Dialog *d = get_dialog(dialog_id);
CHECK(d != nullptr); CHECK(d != nullptr);
@ -27988,6 +27988,14 @@ bool MessagesManager::set_dialog_order(Dialog *d, int64 new_order, bool need_sen
bool is_removed_from_folder = new_order == DEFAULT_ORDER; bool is_removed_from_folder = new_order == DEFAULT_ORDER;
bool is_added_to_folder = d->order == DEFAULT_ORDER; bool is_added_to_folder = d->order == DEFAULT_ORDER;
if (is_removed_from_folder) {
list.in_memory_total_count_--;
} else if (is_added_to_folder) {
list.in_memory_total_count_++;
}
CHECK(static_cast<int32>(list.ordered_dialogs_.size()) <= list.in_memory_total_count_);
CHECK(static_cast<size_t>(list.in_memory_total_count_) <= list.ordered_server_dialogs_.size());
if (!is_loaded_from_database && had_unread_counter != has_unread_counter && !td_->auth_manager_->is_bot()) { if (!is_loaded_from_database && had_unread_counter != has_unread_counter && !td_->auth_manager_->is_bot()) {
auto unread_count = d->server_unread_count + d->local_unread_count; auto unread_count = d->server_unread_count + d->local_unread_count;
const char *change_source = had_unread_counter ? "on_dialog_leave" : "on_dialog_join"; const char *change_source = had_unread_counter ? "on_dialog_leave" : "on_dialog_join";

View File

@ -1213,9 +1213,10 @@ class MessagesManager : public Actor {
int32 unread_dialog_muted_count_ = 0; int32 unread_dialog_muted_count_ = 0;
int32 unread_dialog_marked_count_ = 0; int32 unread_dialog_marked_count_ = 0;
int32 unread_dialog_muted_marked_count_ = 0; int32 unread_dialog_muted_marked_count_ = 0;
int32 in_memory_total_count_ = 0;
std::set<DialogDate> ordered_dialogs_; std::set<DialogDate> ordered_dialogs_; // all dialogs with date <= last_dialog_date_
std::set<DialogDate> ordered_server_dialogs_; std::set<DialogDate> ordered_server_dialogs_; // all known dialogs, including with default order
// date of last dialog in the dialog list // date of last dialog in the dialog list
// last_dialog_date_ == min(last_server_dialog_date_, last_secret_chat_dialog_date_) // last_dialog_date_ == min(last_server_dialog_date_, last_secret_chat_dialog_date_)