Automatically call update_group_call_dialog in set_group_call_participant_count.

This commit is contained in:
levlam 2021-03-19 03:30:39 +03:00
parent af7e26bc49
commit cebcdbd88b
2 changed files with 8 additions and 10 deletions

View File

@ -1315,8 +1315,6 @@ void GroupCallManager::on_get_group_call_participants(
} }
set_group_call_participant_count(group_call, real_participant_count, "on_get_group_call_participants"); set_group_call_participant_count(group_call, real_participant_count, "on_get_group_call_participants");
need_update = true; need_update = true;
update_group_call_dialog(group_call, "on_get_group_call_participants");
} }
if (!is_empty && is_sync && group_call->loaded_all_participants && group_call->participant_count > 50) { if (!is_empty && is_sync && group_call->loaded_all_participants && group_call->participant_count > 50) {
group_call->loaded_all_participants = false; group_call->loaded_all_participants = false;
@ -1404,7 +1402,6 @@ void GroupCallManager::on_update_group_call_participants(
if (diff != 0 && (group_call->participant_count != 0 || diff > 0)) { if (diff != 0 && (group_call->participant_count != 0 || diff > 0)) {
set_group_call_participant_count(group_call, group_call->participant_count + diff, set_group_call_participant_count(group_call, group_call->participant_count + diff,
"on_update_group_call_participants"); "on_update_group_call_participants");
update_group_call_dialog(group_call, "on_update_group_call_participants");
need_update = true; need_update = true;
} }
} }
@ -1580,7 +1577,6 @@ bool GroupCallManager::process_pending_group_call_participant_updates(InputGroup
set_group_call_participant_count(group_call, group_call->participant_count + diff, set_group_call_participant_count(group_call, group_call->participant_count + diff,
"process_pending_group_call_participant_updates"); "process_pending_group_call_participant_updates");
need_update = true; need_update = true;
update_group_call_dialog(group_call, "process_pending_group_call_participant_updates");
} }
if (is_left && group_call->is_joined) { if (is_left && group_call->is_joined) {
on_group_call_left_impl(group_call, need_rejoin); on_group_call_left_impl(group_call, need_rejoin);
@ -2168,9 +2164,8 @@ void GroupCallManager::join_group_call(GroupCallId group_call_id, DialogId as_di
int diff = process_group_call_participant(input_group_call_id, std::move(participant)); int diff = process_group_call_participant(input_group_call_id, std::move(participant));
if (diff != 0) { if (diff != 0) {
CHECK(diff == 1); CHECK(diff == 1);
set_group_call_participant_count(group_call, group_call->participant_count + diff, "join_group_call"); set_group_call_participant_count(group_call, group_call->participant_count + diff, "join_group_call", true);
need_update = true; need_update = true;
update_group_call_dialog(group_call, "join_group_call", true);
} }
} }
@ -3452,7 +3447,7 @@ InputGroupCallId GroupCallManager::update_group_call(const tl_object_ptr<telegra
if (!join_params.empty()) { if (!join_params.empty()) {
need_update |= on_join_group_call_response(input_group_call_id, std::move(join_params)); need_update |= on_join_group_call_response(input_group_call_id, std::move(join_params));
} }
update_group_call_dialog(group_call, "update_group_call"); // must be after join response is processed update_group_call_dialog(group_call, "update_group_call", false); // must be after join response is processed
if (need_update) { if (need_update) {
send_update_group_call(group_call, "update_group_call"); send_update_group_call(group_call, "update_group_call");
} }
@ -3648,7 +3643,8 @@ DialogId GroupCallManager::set_group_call_participant_is_speaking_by_source(Inpu
return DialogId(); return DialogId();
} }
void GroupCallManager::set_group_call_participant_count(GroupCall *group_call, int32 count, const char *source) { void GroupCallManager::set_group_call_participant_count(GroupCall *group_call, int32 count, const char *source,
bool force_update) {
CHECK(group_call != nullptr); CHECK(group_call != nullptr);
LOG(DEBUG) << "Set " << group_call->group_call_id << " participant count to " << count << " from " << source; LOG(DEBUG) << "Set " << group_call->group_call_id << " participant count to " << count << " from " << source;
if (count < 0) { if (count < 0) {
@ -3658,6 +3654,7 @@ void GroupCallManager::set_group_call_participant_count(GroupCall *group_call, i
} else { } else {
group_call->participant_count = count; group_call->participant_count = count;
} }
update_group_call_dialog(group_call, source, force_update);
} }
void GroupCallManager::update_group_call_dialog(const GroupCall *group_call, const char *source, bool force) { void GroupCallManager::update_group_call_dialog(const GroupCall *group_call, const char *source, bool force) {

View File

@ -277,9 +277,10 @@ class GroupCallManager : public Actor {
void try_clear_group_call_participants(InputGroupCallId input_group_call_id); void try_clear_group_call_participants(InputGroupCallId input_group_call_id);
static void set_group_call_participant_count(GroupCall *group_call, int32 count, const char *source); void set_group_call_participant_count(GroupCall *group_call, int32 count, const char *source,
bool force_update = false);
void update_group_call_dialog(const GroupCall *group_call, const char *source, bool force = false); void update_group_call_dialog(const GroupCall *group_call, const char *source, bool force);
vector<td_api::object_ptr<td_api::groupCallRecentSpeaker>> get_recent_speakers(const GroupCall *group_call, vector<td_api::object_ptr<td_api::groupCallRecentSpeaker>> get_recent_speakers(const GroupCall *group_call,
bool for_update); bool for_update);