Allow mute for me even force-muted participants.

This commit is contained in:
John Preston 2021-05-31 15:46:15 +04:00
parent ce091b0b63
commit 4080fa9bdc
5 changed files with 62 additions and 42 deletions

View file

@ -434,6 +434,7 @@ PeerListRow::PeerListRow(not_null<PeerData*> peer)
PeerListRow::PeerListRow(not_null<PeerData*> peer, PeerListRowId id)
: _id(id)
, _peer(peer)
, _hidden(false)
, _initialized(false)
, _isSearchResult(false)
, _isSavedMessagesChat(false)
@ -442,6 +443,7 @@ PeerListRow::PeerListRow(not_null<PeerData*> peer, PeerListRowId id)
PeerListRow::PeerListRow(PeerListRowId id)
: _id(id)
, _hidden(false)
, _initialized(false)
, _isSearchResult(false)
, _isSavedMessagesChat(false)

View file

@ -243,7 +243,7 @@ private:
base::flat_set<QChar> _nameFirstLetters;
int _absoluteIndex = -1;
State _disabledState = State::Active;
bool _hidden = false;
bool _hidden : 1;
bool _initialized : 1;
bool _isSearchResult : 1;
bool _isSavedMessagesChat : 1;

View file

@ -1299,16 +1299,14 @@ void Members::Controller::addMuteActionsToContextMenu(
not_null<PeerData*> participantPeer,
bool participantIsCallAdmin,
not_null<Row*> row) {
const auto muteString = [=] {
return (_peer->canManageGroupCall()
? tr::lng_group_call_context_mute
: tr::lng_group_call_context_mute_for_me)(tr::now);
};
const auto unmuteString = [=] {
return (_peer->canManageGroupCall()
? tr::lng_group_call_context_unmute
: tr::lng_group_call_context_unmute_for_me)(tr::now);
const auto muteUnmuteString = [=](bool muted, bool mutedByMe) {
return (muted && _peer->canManageGroupCall())
? tr::lng_group_call_context_unmute(tr::now)
: mutedByMe
? tr::lng_group_call_context_unmute_for_me(tr::now)
: _peer->canManageGroupCall()
? tr::lng_group_call_context_mute(tr::now)
: tr::lng_group_call_context_mute_for_me(tr::now);
};
const auto toggleMute = crl::guard(this, [=](bool mute, bool local) {
@ -1329,13 +1327,13 @@ void Members::Controller::addMuteActionsToContextMenu(
});
const auto muteState = row->state();
const auto isMuted = (muteState == Row::State::Muted)
|| (muteState == Row::State::RaisedHand)
|| (muteState == Row::State::MutedByMe);
const auto muted = (muteState == Row::State::Muted)
|| (muteState == Row::State::RaisedHand);
const auto mutedByMe = row->mutedByMe();
auto mutesFromVolume = rpl::never<bool>() | rpl::type_erased();
if (!isMuted || _call->joinAs() == participantPeer) {
if (!muted || _call->joinAs() == participantPeer) {
auto otherParticipantStateValue
= _call->otherParticipantStateValue(
) | rpl::filter([=](const Group::ParticipantState &data) {
@ -1348,7 +1346,7 @@ void Members::Controller::addMuteActionsToContextMenu(
otherParticipantStateValue,
row->volume(),
Group::kMaxVolume,
isMuted);
muted);
mutesFromVolume = volumeItem->toggleMuteRequests();
@ -1397,20 +1395,32 @@ void Members::Controller::addMuteActionsToContextMenu(
auto callback = [=] {
const auto state = row->state();
const auto muted = (state == Row::State::Muted)
|| (state == Row::State::RaisedHand)
|| (state == Row::State::MutedByMe);
toggleMute(!muted, false);
|| (state == Row::State::RaisedHand);
const auto mutedByMe = row->mutedByMe();
toggleMute(!mutedByMe && (!_call->canManage() || !muted), false);
};
return menu->addAction(
isMuted ? unmuteString() : muteString(),
muteUnmuteString(muted, mutedByMe),
std::move(callback));
}();
if (muteAction) {
std::move(
mutesFromVolume
) | rpl::start_with_next([=](bool muted) {
muteAction->setText(muted ? unmuteString() : muteString());
) | rpl::start_with_next([=](bool mutedFromVolume) {
const auto state = _call->canManage()
? (mutedFromVolume
? (row->raisedHandRating()
? Row::State::RaisedHand
: Row::State::Muted)
: Row::State::Inactive)
: row->state();
const auto muted = (state == Row::State::Muted)
|| (state == Row::State::RaisedHand);
const auto mutedByMe = _call->canManage()
? false
: mutedFromVolume;
muteAction->setText(muteUnmuteString(muted, mutedByMe));
}, menu->lifetime());
}
}

View file

@ -126,7 +126,12 @@ MembersRow::MembersRow(
not_null<MembersRowDelegate*> delegate,
not_null<PeerData*> participantPeer)
: PeerListRow(participantPeer)
, _delegate(delegate) {
, _delegate(delegate)
, _sounding(false)
, _speaking(false)
, _raisedHandStatus(false)
, _skipLevelUpdate(false)
, _mutedByMe(false) {
refreshStatus();
_aboutText = participantPeer->about();
}
@ -147,25 +152,27 @@ void MembersRow::updateState(
setState(State::Invited);
setSounding(false);
setSpeaking(false);
_mutedByMe = false;
_raisedHandRating = 0;
} else if (!participant->muted
|| (participant->sounding && participant->ssrc != 0)) {
setState(participant->mutedByMe ? State::MutedByMe : State::Active);
setState(State::Active);
setSounding(participant->sounding && participant->ssrc != 0);
setSpeaking(participant->speaking && participant->ssrc != 0);
_mutedByMe = participant->mutedByMe;
_raisedHandRating = 0;
} else if (participant->canSelfUnmute) {
setState(participant->mutedByMe
? State::MutedByMe
: State::Inactive);
setState(State::Inactive);
setSounding(false);
setSpeaking(false);
_mutedByMe = participant->mutedByMe;
_raisedHandRating = 0;
} else {
_raisedHandRating = participant->raisedHandRating;
setState(_raisedHandRating ? State::RaisedHand : State::Muted);
setSounding(false);
setSpeaking(false);
_mutedByMe = participant->mutedByMe;
_raisedHandRating = participant->raisedHandRating;
setState(_raisedHandRating ? State::RaisedHand : State::Muted);
}
refreshStatus();
}
@ -182,7 +189,7 @@ void MembersRow::setSpeaking(bool speaking) {
st::widgetFadeDuration);
if (!_speaking
|| (_state == State::MutedByMe)
|| _mutedByMe
|| (_state == State::Muted)
|| (_state == State::RaisedHand)) {
if (_statusIcon) {
@ -381,11 +388,10 @@ void MembersRow::paintBlobs(
return;
}
auto size = sizew;
const auto mutedByMe = (_state == State::MutedByMe);
const auto shift = QPointF(x + size / 2., y + size / 2.);
auto hq = PainterHighQualityEnabler(p);
p.translate(shift);
const auto brush = mutedByMe
const auto brush = _mutedByMe
? st::groupCallMemberMutedIcon->b
: anim::brush(
st::groupCallMemberInactiveStatus,
@ -614,7 +620,7 @@ void MembersRow::paintComplexStatusText(
: QString();
if (about.isEmpty()
&& _state != State::Invited
&& _state != State::MutedByMe) {
&& !_mutedByMe) {
paintStatusIcon(p, x, y, st, font, selected, narrowMode);
const auto translatedWidth = statusIconWidth(narrowMode);
@ -640,7 +646,7 @@ void MembersRow::paintComplexStatusText(
p.setFont(font);
if (style == MembersRowStyle::Video) {
p.setPen(st::groupCallVideoSubTextFg);
} else if (_state == State::MutedByMe) {
} else if (_mutedByMe) {
p.setPen(st::groupCallMemberMutedIcon);
} else {
p.setPen(st::groupCallMemberNotJoinedStatus);
@ -649,7 +655,7 @@ void MembersRow::paintComplexStatusText(
x,
y,
outerWidth,
(_state == State::MutedByMe
(_mutedByMe
? tr::lng_group_call_muted_by_me_status(tr::now)
: !about.isEmpty()
? font->m.elidedText(about, Qt::ElideRight, availableWidth)
@ -715,12 +721,11 @@ MembersRowDelegate::IconState MembersRow::computeIconState(
(_state == State::Active) ? 1. : 0.);
const auto muted = _mutedAnimation.value(
(_state == State::Muted || _state == State::RaisedHand) ? 1. : 0.);
const auto mutedByMe = (_state == State::MutedByMe);
return {
.speaking = speaking,
.active = active,
.muted = muted,
.mutedByMe = (_state == State::MutedByMe),
.mutedByMe = _mutedByMe,
.raisedHand = (_state == State::RaisedHand),
.invited = (_state == State::Invited),
.style = style,

View file

@ -73,7 +73,6 @@ public:
Inactive,
Muted,
RaisedHand,
MutedByMe,
Invited,
};
@ -95,6 +94,9 @@ public:
[[nodiscard]] bool speaking() const {
return _speaking;
}
[[nodiscard]] bool mutedByMe() const {
return _mutedByMe;
}
[[nodiscard]] crl::time speakingLastTime() const {
return _speakingLastTime;
}
@ -212,10 +214,11 @@ private:
uint64 _raisedHandRating = 0;
uint32 _ssrc = 0;
int _volume = Group::kDefaultVolume;
bool _sounding = false;
bool _speaking = false;
bool _raisedHandStatus = false;
bool _skipLevelUpdate = false;
bool _sounding : 1;
bool _speaking : 1;
bool _raisedHandStatus : 1;
bool _skipLevelUpdate : 1;
bool _mutedByMe : 1;
};