diff --git a/td/telegram/MessagesManager.cpp b/td/telegram/MessagesManager.cpp index 0fda23a98..736d2b44f 100644 --- a/td/telegram/MessagesManager.cpp +++ b/td/telegram/MessagesManager.cpp @@ -35953,6 +35953,9 @@ MessagesManager::Dialog *MessagesManager::add_new_dialog(unique_ptr &&d, auto dialog_it = dialogs_.emplace(dialog_id, std::move(d)).first; + CHECK(!being_added_new_dialog_id_.is_valid()); + being_added_new_dialog_id_ = dialog_id; + loaded_dialogs_.erase(dialog_id); Dialog *dialog = dialog_it->second.get(); @@ -35961,6 +35964,8 @@ MessagesManager::Dialog *MessagesManager::add_new_dialog(unique_ptr &&d, send_update_new_chat(dialog); + being_added_new_dialog_id_ = DialogId(); + fix_new_dialog(dialog, std::move(last_database_message), last_database_message_id, order, last_clear_history_date, last_clear_history_message_id, default_join_group_call_as_dialog_id, default_send_message_as_dialog_id, need_drop_default_send_message_as_dialog_id, is_loaded_from_database); @@ -36094,6 +36099,7 @@ void MessagesManager::fix_new_dialog(Dialog *d, unique_ptr &&last_datab CHECK(counter_message.first > 0); counter_message.first--; if (counter_message.first == 0) { + LOG(INFO) << "Add postponed last database message in " << pending_dialog_id; add_dialog_last_database_message(get_dialog(pending_dialog_id), std::move(counter_message.second)); pending_add_dialog_last_database_message_.erase(pending_dialog_id); } diff --git a/td/telegram/MessagesManager.h b/td/telegram/MessagesManager.h index 9626eeed7..889114798 100644 --- a/td/telegram/MessagesManager.h +++ b/td/telegram/MessagesManager.h @@ -3679,6 +3679,7 @@ class MessagesManager final : public Actor { DialogId being_added_dialog_id_; DialogId being_added_by_new_message_dialog_id_; + DialogId being_added_new_dialog_id_; DialogId debug_channel_difference_dialog_;