2
0
mirror of https://github.com/kotatogram/kotatogram-desktop synced 2025-08-30 22:25:12 +00:00

Track three-state muted value.

This commit is contained in:
John Preston
2020-11-28 10:18:46 +03:00
parent c8dd486410
commit d18b29efb8
4 changed files with 59 additions and 18 deletions

View File

@@ -115,13 +115,18 @@ void TopBar::initControls() {
if (const auto call = _call.get()) {
call->setMuted(!call->muted());
} else if (const auto group = _groupCall.get()) {
group->setMuted(!group->muted());
if (group->muted() != MuteState::ForceMuted) {
group->setMuted((group->muted() == MuteState::Active)
? MuteState::Muted
: MuteState::Active);
}
}
});
using namespace rpl::mappers;
auto muted = _call
? _call->mutedValue()
: _groupCall->mutedValue();
: (_groupCall->mutedValue() | rpl::map(_1 != MuteState::Active));
std::move(
muted
) | rpl::start_with_next([=](bool muted) {
@@ -129,6 +134,18 @@ void TopBar::initControls() {
update();
}, lifetime());
if (_groupCall) {
_groupCall->mutedValue(
) | rpl::start_with_next([=](MuteState state) {
if (state == MuteState::ForceMuted) {
_mute->clearState();
}
_mute->setAttribute(
Qt::WA_TransparentForMouseEvents,
(state == MuteState::ForceMuted));
}, _mute->lifetime());
}
if (const auto call = _call.get()) {
call->user()->session().changes().peerUpdates(
Data::PeerUpdate::Flag::Name