From b54a2aa40b32e172b18af4897fff8334c6a64782 Mon Sep 17 00:00:00 2001 From: John Preston Date: Sat, 28 Nov 2020 10:41:33 +0300 Subject: [PATCH] Apply self mute status locally. --- .../SourceFiles/calls/calls_group_call.cpp | 47 ++++++++++++------- Telegram/SourceFiles/data/data_group_call.cpp | 4 +- Telegram/ThirdParty/tgcalls | 2 +- 3 files changed, 32 insertions(+), 21 deletions(-) diff --git a/Telegram/SourceFiles/calls/calls_group_call.cpp b/Telegram/SourceFiles/calls/calls_group_call.cpp index 4026beaaa0..387dfb026a 100644 --- a/Telegram/SourceFiles/calls/calls_group_call.cpp +++ b/Telegram/SourceFiles/calls/calls_group_call.cpp @@ -175,24 +175,36 @@ void GroupCall::applySelfInCallLocally() { if (!call || call->id() != _id) { return; } - const auto my = [&] { - const auto self = _channel->session().userId(); - const auto now = base::unixtime::now(); - using Flag = MTPDgroupCallParticipant::Flag; - return MTP_groupCallParticipant( - MTP_flags((_mySsrc ? Flag(0) : Flag::f_left) - | ((_muted.current() != MuteState::Active) - ? Flag::f_muted - : Flag(0))), - MTP_int(self), - MTP_int(now), - MTP_int(0), - MTP_int(_mySsrc)); - }; + using Flag = MTPDgroupCallParticipant::Flag; + const auto &participants = call->participants(); + const auto self = _channel->session().user(); + const auto i = ranges::find( + participants, + self, + &Data::GroupCall::Participant::user); + const auto date = (i != end(participants)) + ? i->date + : base::unixtime::now(); + const auto lastActive = (i != end(participants)) + ? i->lastActive + : TimeId(0); + const auto muted = (_muted.current() != MuteState::Active); + const auto cantSelfUnmute = (_muted.current() == MuteState::ForceMuted); + const auto flags = (cantSelfUnmute ? Flag(0) : Flag::f_can_self_unmute) + | (lastActive ? Flag::f_active_date : Flag(0)) + | (_mySsrc ? Flag(0) : Flag::f_left) + | (muted ? Flag::f_muted : Flag(0)); call->applyUpdateChecked( MTP_updateGroupCallParticipants( inputCall(), - MTP_vector(1, my()), + MTP_vector( + 1, + MTP_groupCallParticipant( + MTP_flags(flags), + MTP_int(self->bareId()), + MTP_int(date), + MTP_int(lastActive), + MTP_int(_mySsrc))), MTP_int(0)).c_updateGroupCallParticipants()); } @@ -237,6 +249,7 @@ void GroupCall::finish(FinishType type) { void GroupCall::setMuted(MuteState mute) { _muted = mute; + applySelfInCallLocally(); } void GroupCall::handleUpdate(const MTPGroupCall &call) { @@ -396,9 +409,7 @@ void GroupCall::createAndStartController() { } void GroupCall::myLevelUpdated(float level) { - if (level > 0.) { - - } + LOG(("Level: %1").arg(level)); } void GroupCall::sendMutedUpdate() { diff --git a/Telegram/SourceFiles/data/data_group_call.cpp b/Telegram/SourceFiles/data/data_group_call.cpp index dd0040ba3a..f5e6ec96fe 100644 --- a/Telegram/SourceFiles/data/data_group_call.cpp +++ b/Telegram/SourceFiles/data/data_group_call.cpp @@ -198,7 +198,7 @@ void GroupCall::applyParticipantsSlice( .date = data.vdate().v, .source = uint32(data.vsource().v), .muted = data.is_muted(), - .canSelfUnmute = data.is_can_self_unmute(), + .canSelfUnmute = !data.is_muted() || data.is_can_self_unmute(), }; if (i == end(_participants)) { _participants.push_back(value); @@ -236,7 +236,7 @@ void GroupCall::applyParticipantsMutes( &Participant::user); if (i != end(_participants)) { i->muted = data.is_muted(); - i->canSelfUnmute = data.is_can_self_unmute(); + i->canSelfUnmute = !i->muted || data.is_can_self_unmute(); _participantUpdates.fire({ .participant = *i, }); diff --git a/Telegram/ThirdParty/tgcalls b/Telegram/ThirdParty/tgcalls index ac86c0ee86..10d63157e4 160000 --- a/Telegram/ThirdParty/tgcalls +++ b/Telegram/ThirdParty/tgcalls @@ -1 +1 @@ -Subproject commit ac86c0ee86293d6fced7dcb48a8c93657f18a7f3 +Subproject commit 10d63157e4ebdf71d1ea3694bef2ab1f7d7f033c