Move yet_unsent_thread_message_ids out of Dialog.

This commit is contained in:
levlam 2023-03-15 16:59:23 +03:00
parent 78d5146188
commit 7d99fc50ed
2 changed files with 9 additions and 9 deletions

View File

@ -16661,12 +16661,12 @@ void MessagesManager::on_message_deleted(Dialog *d, Message *m, bool is_permanen
CHECK(m->message_id.is_valid()); CHECK(m->message_id.is_valid());
if (m->message_id.is_yet_unsent() && !m->message_id.is_scheduled() && m->top_thread_message_id.is_valid()) { if (m->message_id.is_yet_unsent() && !m->message_id.is_scheduled() && m->top_thread_message_id.is_valid()) {
auto it = d->yet_unsent_thread_message_ids.find(m->top_thread_message_id); auto it = yet_unsent_thread_message_ids_.find({d->dialog_id, m->top_thread_message_id});
CHECK(it != d->yet_unsent_thread_message_ids.end()); CHECK(it != yet_unsent_thread_message_ids_.end());
auto is_deleted = it->second.erase(m->message_id) > 0; auto is_deleted = it->second.erase(m->message_id) > 0;
CHECK(is_deleted); CHECK(is_deleted);
if (it->second.empty()) { if (it->second.empty()) {
d->yet_unsent_thread_message_ids.erase(it); yet_unsent_thread_message_ids_.erase(it);
} }
} }
if (d->open_count > 0) { if (d->open_count > 0) {
@ -22846,8 +22846,8 @@ std::pair<DialogId, vector<MessageId>> MessagesManager::get_message_thread_histo
return {}; return {};
} }
auto yet_unsent_it = d->yet_unsent_thread_message_ids.find(top_thread_full_message_id.get_message_id()); auto yet_unsent_it = yet_unsent_thread_message_ids_.find(top_thread_full_message_id);
if (yet_unsent_it != d->yet_unsent_thread_message_ids.end()) { if (yet_unsent_it != yet_unsent_thread_message_ids_.end()) {
const std::set<MessageId> &message_ids = yet_unsent_it->second; const std::set<MessageId> &message_ids = yet_unsent_it->second;
auto merge_message_ids = get_message_history_slice(message_ids.begin(), message_ids.lower_bound(from_message_id), auto merge_message_ids = get_message_history_slice(message_ids.begin(), message_ids.lower_bound(from_message_id),
message_ids.end(), from_message_id, offset, limit); message_ids.end(), from_message_id, offset, limit);
@ -36113,7 +36113,8 @@ MessagesManager::Message *MessagesManager::add_message_to_dialog(Dialog *d, uniq
} }
if (m->message_id.is_yet_unsent() && !m->message_id.is_scheduled() && m->top_thread_message_id.is_valid()) { if (m->message_id.is_yet_unsent() && !m->message_id.is_scheduled() && m->top_thread_message_id.is_valid()) {
auto is_inserted = d->yet_unsent_thread_message_ids[m->top_thread_message_id].insert(m->message_id).second; auto is_inserted =
yet_unsent_thread_message_ids_[FullMessageId{dialog_id, m->top_thread_message_id}].insert(m->message_id).second;
CHECK(is_inserted); CHECK(is_inserted);
} }

View File

@ -1419,9 +1419,6 @@ class MessagesManager final : public Actor {
// application start, used to guarantee that all assigned message identifiers // application start, used to guarantee that all assigned message identifiers
// are different // are different
FlatHashMap<MessageId, std::set<MessageId>, MessageIdHash>
yet_unsent_thread_message_ids; // top_thread_message_id -> yet unsent message IDs
FlatHashMap<ScheduledServerMessageId, int32, ScheduledServerMessageIdHash> scheduled_message_date; FlatHashMap<ScheduledServerMessageId, int32, ScheduledServerMessageIdHash> scheduled_message_date;
FlatHashMap<int32, MessageId> last_assigned_scheduled_message_id; // date -> message_id FlatHashMap<int32, MessageId> last_assigned_scheduled_message_id; // date -> message_id
@ -3755,6 +3752,8 @@ class MessagesManager final : public Actor {
FlatHashMap<DialogId, MessageId, DialogIdHash> previous_repaired_read_inbox_max_message_id_; FlatHashMap<DialogId, MessageId, DialogIdHash> previous_repaired_read_inbox_max_message_id_;
FlatHashMap<FullMessageId, MessageId, FullMessageIdHash> yet_unsent_full_message_id_to_persistent_message_id_; FlatHashMap<FullMessageId, MessageId, FullMessageIdHash> yet_unsent_full_message_id_to_persistent_message_id_;
FlatHashMap<FullMessageId, std::set<MessageId>, FullMessageIdHash>
yet_unsent_thread_message_ids_; // {dialog_id, top_thread_message_id} -> yet unsent message IDs
struct PendingReaction { struct PendingReaction {
int32 query_count = 0; int32 query_count = 0;