From 81e08599dca5081e9261facb4a34234c9c631f89 Mon Sep 17 00:00:00 2001 From: John Preston Date: Tue, 9 Mar 2021 17:34:15 +0400 Subject: [PATCH] Raising hands reorder participants only for admins. --- .../SourceFiles/calls/calls_group_members.cpp | 27 ++++++++++++++----- 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/Telegram/SourceFiles/calls/calls_group_members.cpp b/Telegram/SourceFiles/calls/calls_group_members.cpp index e66085eced..7f826e59e0 100644 --- a/Telegram/SourceFiles/calls/calls_group_members.cpp +++ b/Telegram/SourceFiles/calls/calls_group_members.cpp @@ -1114,6 +1114,9 @@ bool MembersController::needToReorder(not_null row) const { if (row->speaking()) { return !allRowsAboveAreSpeaking(row); + } else if (!_peer->canManageGroupCall()) { + // Raising hands reorder participants only for voice chat admins. + return false; } const auto rating = row->raisedHandRating(); @@ -1152,7 +1155,7 @@ void MembersController::checkRowPosition(not_null row) { // Or someone raised hand and has force muted above him. // Or someone was forced muted and had can_unmute_self below him. Sort. static constexpr auto kTop = std::numeric_limits::max(); - const auto proj = [&](const PeerListRow &other) { + const auto projForAdmin = [&](const PeerListRow &other) { const auto &real = static_cast(other); return real.speaking() // Speaking 'row' to the top, all other speaking below it. @@ -1166,11 +1169,23 @@ void MembersController::checkRowPosition(not_null row) { // All not force-muted lie between raised hands and speaking. : (std::numeric_limits::max() - 2); }; - delegate()->peerListSortRows([&]( - const PeerListRow &a, - const PeerListRow &b) { - return proj(a) > proj(b); - }); + const auto projForOther = [&](const PeerListRow &other) { + const auto &real = static_cast(other); + return real.speaking() + // Speaking 'row' to the top, all other speaking below it. + ? (&real == row.get() ? kTop : (kTop - 1)) + : 0ULL; + }; + + using Comparator = Fn; + const auto makeComparator = [&](const auto &proj) -> Comparator { + return [&](const PeerListRow &a, const PeerListRow &b) { + return proj(a) > proj(b); + }; + }; + delegate()->peerListSortRows(_peer->canManageGroupCall() + ? makeComparator(projForAdmin) + : makeComparator(projForOther)); } void MembersController::updateRow(