From e5f31dbe8ed915ce419a31832c3d55708883f68d Mon Sep 17 00:00:00 2001 From: John Preston Date: Sat, 5 Apr 2025 09:57:47 +0500 Subject: [PATCH] Remove unnecessary stale participant check. --- Telegram/SourceFiles/data/data_group_call.cpp | 55 ++----------------- Telegram/SourceFiles/data/data_group_call.h | 4 +- 2 files changed, 6 insertions(+), 53 deletions(-) diff --git a/Telegram/SourceFiles/data/data_group_call.cpp b/Telegram/SourceFiles/data/data_group_call.cpp index 1dc6fef8ca..0318001421 100644 --- a/Telegram/SourceFiles/data/data_group_call.cpp +++ b/Telegram/SourceFiles/data/data_group_call.cpp @@ -108,7 +108,6 @@ GroupCall::~GroupCall() { } api().request(_unknownParticipantPeersRequestId).cancel(); api().request(_participantsRequestId).cancel(); - api().request(_checkStaleRequestId).cancel(); api().request(_reloadRequestId).cancel(); } @@ -212,9 +211,6 @@ void GroupCall::setParticipantsLoaded() { } void GroupCall::checkStaleParticipants() { - if (_checkStaleRequestId) { - return; - } const auto &list = _participantsWithAccess.current(); if (list.empty()) { return; @@ -227,57 +223,16 @@ void GroupCall::checkStaleParticipants() { existing.emplace(id); } } - if (list.size() > existing.size()) { - checkStaleRequest(); - return; - } + auto stale = base::flat_set(); for (const auto &id : list) { if (!existing.contains(id)) { - checkStaleRequest(); - return; + stale.reserve(list.size()); + stale.emplace(id); } } -} - -void GroupCall::checkStaleRequest() { - if (_checkStaleRequestId) { - return; + if (!stale.empty()) { + _staleParticipantIds.fire(std::move(stale)); } - _checkStaleRequestId = api().request(MTPphone_GetGroupParticipants( - input(), - MTP_vector(), // ids - MTP_vector(), // ssrcs - MTP_string(QString()), - MTP_int(kMaxConferenceMembers + 10) - )).done([=](const MTPphone_GroupParticipants &result) { - _checkStaleRequestId = 0; - const auto &list = _participantsWithAccess.current(); - if (list.empty()) { - return; - } - auto existing = base::flat_set(); - const auto &data = result.data(); - existing.reserve(data.vparticipants().v.size() + 1); - existing.emplace(session().userId()); - for (const auto &participant : data.vparticipants().v) { - const auto peerId = peerFromMTP(participant.data().vpeer()); - if (const auto id = peerToUser(peerId)) { - existing.emplace(id); - } - } - auto stale = base::flat_set(); - for (const auto &id : list) { - if (!existing.contains(id)) { - stale.reserve(list.size()); - stale.emplace(id); - } - } - if (!stale.empty()) { - _staleParticipantIds.fire(std::move(stale)); - } - }).fail([=] { - _checkStaleRequestId = 0; - }).send(); } bool GroupCall::processSavedFullCall() { diff --git a/Telegram/SourceFiles/data/data_group_call.h b/Telegram/SourceFiles/data/data_group_call.h index 54c6990015..da804a442a 100644 --- a/Telegram/SourceFiles/data/data_group_call.h +++ b/Telegram/SourceFiles/data/data_group_call.h @@ -30,7 +30,7 @@ namespace Data { [[nodiscard]] const std::string &RtmpEndpointId(); -inline constexpr auto kMaxConferenceMembers = 10; +inline constexpr auto kMaxConferenceMembers = 200; struct LastSpokeTimes { crl::time anything = 0; @@ -157,7 +157,6 @@ public: -> rpl::producer>; void setParticipantsLoaded(); void checkStaleParticipants(); - void checkStaleRequest(); void enqueueUpdate(const MTPUpdate &update); void applyLocalUpdate( @@ -269,7 +268,6 @@ private: rpl::variable> _participantsWithAccess; rpl::event_stream> _staleParticipantIds; - mtpRequestId _checkStaleRequestId = 0; rpl::lifetime _checkStaleLifetime; bool _creator : 1 = false;