Save expected active group call ID.

This commit is contained in:
levlam 2021-04-12 02:49:28 +03:00
parent 47a7bc05e2
commit 2ddeead75f
2 changed files with 10 additions and 1 deletions

View File

@ -8222,7 +8222,11 @@ void MessagesManager::repair_dialog_active_group_call_id(DialogId dialog_id) {
void MessagesManager::do_repair_dialog_active_group_call_id(DialogId dialog_id) {
Dialog *d = get_dialog(dialog_id);
CHECK(d != nullptr);
if (!d->has_active_group_call || d->active_group_call_id.is_valid()) {
bool need_repair_active_group_call_id = d->has_active_group_call && !d->active_group_call_id.is_valid();
bool need_repair_expected_group_call_id =
d->has_expected_active_group_call_id && d->active_group_call_id != d->expected_active_group_call_id;
d->has_expected_active_group_call_id = false;
if (!need_repair_active_group_call_id && !need_repair_expected_group_call_id) {
return;
}
if (!have_input_peer(dialog_id, AccessRights::Read)) {
@ -36064,11 +36068,14 @@ void MessagesManager::speculatively_update_active_group_call_id(Dialog *d, const
InputGroupCallId input_group_call_id;
bool is_ended;
std::tie(input_group_call_id, is_ended) = get_message_content_group_call_info(m->content.get());
d->has_expected_active_group_call_id = true;
if (is_ended) {
d->expected_active_group_call_id = InputGroupCallId();
if (d->active_group_call_id == input_group_call_id) {
on_update_dialog_group_call_id(d->dialog_id, InputGroupCallId());
}
} else {
d->expected_active_group_call_id = input_group_call_id;
if (d->active_group_call_id != input_group_call_id) {
repair_dialog_active_group_call_id(d->dialog_id);
}

View File

@ -1168,6 +1168,7 @@ class MessagesManager : public Actor {
std::unordered_set<MessageId, MessageIdHash> updated_read_history_message_ids;
LogEventIdWithGeneration set_folder_id_log_event_id;
InputGroupCallId active_group_call_id;
InputGroupCallId expected_active_group_call_id;
DialogId default_join_group_call_as_dialog_id;
FolderId folder_id;
@ -1244,6 +1245,7 @@ class MessagesManager : public Actor {
bool has_active_group_call = false;
bool is_group_call_empty = false;
bool is_message_ttl_setting_inited = false;
bool has_expected_active_group_call_id = false;
bool increment_view_counter = false;