mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 22:54:01 +02:00
Apply self mute status locally.
This commit is contained in:
parent
7983d33ad5
commit
b54a2aa40b
3 changed files with 32 additions and 21 deletions
|
@ -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<MTPGroupCallParticipant>(1, my()),
|
||||
MTP_vector<MTPGroupCallParticipant>(
|
||||
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() {
|
||||
|
|
|
@ -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,
|
||||
});
|
||||
|
|
2
Telegram/ThirdParty/tgcalls
vendored
2
Telegram/ThirdParty/tgcalls
vendored
|
@ -1 +1 @@
|
|||
Subproject commit ac86c0ee86293d6fced7dcb48a8c93657f18a7f3
|
||||
Subproject commit 10d63157e4ebdf71d1ea3694bef2ab1f7d7f033c
|
Loading…
Add table
Reference in a new issue