mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-08 08:04:08 +02:00
Removed draft volume items from menu in group calls.
This commit is contained in:
parent
50f87cce84
commit
9fed46fb6e
2 changed files with 88 additions and 84 deletions
|
@ -1910,6 +1910,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
"lng_group_call_too_many" = "Sorry, there are too many members in this voice chat. Please try again later.";
|
"lng_group_call_too_many" = "Sorry, there are too many members in this voice chat. Please try again later.";
|
||||||
"lng_group_call_context_mute" = "Mute";
|
"lng_group_call_context_mute" = "Mute";
|
||||||
"lng_group_call_context_unmute" = "Allow to speak";
|
"lng_group_call_context_unmute" = "Allow to speak";
|
||||||
|
"lng_group_call_context_mute_for_me" = "Mute for me";
|
||||||
|
"lng_group_call_context_unmute_for_me" = "Unmute for me";
|
||||||
"lng_group_call_duration_days#one" = "{count} day";
|
"lng_group_call_duration_days#one" = "{count} day";
|
||||||
"lng_group_call_duration_days#other" = "{count} days";
|
"lng_group_call_duration_days#other" = "{count} days";
|
||||||
"lng_group_call_duration_hours#one" = "{count} hour";
|
"lng_group_call_duration_hours#one" = "{count} hour";
|
||||||
|
|
|
@ -1157,30 +1157,6 @@ base::unique_qptr<Ui::PopupMenu> MembersController::createRowContextMenu(
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}();
|
}();
|
||||||
const auto amCallAdmin = _peer->canManageGroupCall();
|
|
||||||
const auto mute = (admin || !amCallAdmin)
|
|
||||||
? (muteState == Row::State::Active)
|
|
||||||
: (muteState != Row::State::Muted);
|
|
||||||
const auto toggleMute = crl::guard(this, [=] {
|
|
||||||
_toggleMuteRequests.fire(Group::MuteRequest{
|
|
||||||
.user = user,
|
|
||||||
.mute = mute,
|
|
||||||
});
|
|
||||||
});
|
|
||||||
const auto toggleMute_ = crl::guard(this, [=](bool mute, bool local) {
|
|
||||||
_toggleMuteRequests.fire(Group::MuteRequest{
|
|
||||||
.user = user,
|
|
||||||
.mute = mute,
|
|
||||||
.locallyOnly = local,
|
|
||||||
});
|
|
||||||
});
|
|
||||||
const auto changeVolume = crl::guard(this, [=](int volume, bool local) {
|
|
||||||
_changeVolumeRequests.fire(Group::VolumeRequest{
|
|
||||||
.user = user,
|
|
||||||
.volume = std::clamp(volume, 1, Group::kMaxVolume),
|
|
||||||
.locallyOnly = local,
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
const auto session = &user->session();
|
const auto session = &user->session();
|
||||||
const auto getCurrentWindow = [=]() -> Window::SessionController* {
|
const auto getCurrentWindow = [=]() -> Window::SessionController* {
|
||||||
|
@ -1231,37 +1207,36 @@ base::unique_qptr<Ui::PopupMenu> MembersController::createRowContextMenu(
|
||||||
_kickMemberRequests.fire_copy(user);
|
_kickMemberRequests.fire_copy(user);
|
||||||
});
|
});
|
||||||
|
|
||||||
if ((muteState != Row::State::Invited)
|
|
||||||
&& amCallAdmin
|
|
||||||
&& (!admin || mute)) {
|
|
||||||
result->addAction(
|
|
||||||
(mute
|
|
||||||
? tr::lng_group_call_context_mute(tr::now)
|
|
||||||
: tr::lng_group_call_context_unmute(tr::now)),
|
|
||||||
toggleMute);
|
|
||||||
}
|
|
||||||
if (real->ssrc() != 0) {
|
if (real->ssrc() != 0) {
|
||||||
if (!amCallAdmin
|
const auto muteString = [=] {
|
||||||
&& ((muteState == Row::State::Active)
|
return (_peer->canManageGroupCall()
|
||||||
|| (real->state() == Row::State::MutedByMe))) {
|
? tr::lng_group_call_context_mute
|
||||||
result->addAction(
|
: tr::lng_group_call_context_mute_for_me)(tr::now);
|
||||||
((muteState == Row::State::Active)
|
};
|
||||||
? "Mute for me"
|
|
||||||
: "Unmute for me"),
|
const auto unmuteString = [=] {
|
||||||
toggleMute);
|
return (_peer->canManageGroupCall()
|
||||||
}
|
? tr::lng_group_call_context_unmute
|
||||||
if (muteState != Row::State::Muted
|
: tr::lng_group_call_context_unmute_for_me)(tr::now);
|
||||||
&& muteState != Row::State::MutedByMe) {
|
};
|
||||||
const auto volume = real->volume();
|
|
||||||
result->addAction(QString("Increase volume (%1%)").arg(volume / 100.), [=] {
|
const auto toggleMute = crl::guard(this, [=](bool mute, bool local) {
|
||||||
changeVolume(volume + 2000, false);
|
_toggleMuteRequests.fire(Group::MuteRequest{
|
||||||
});
|
.user = user,
|
||||||
result->addAction(QString("Decrease volume (%1%)").arg(volume / 100.), [=] {
|
.mute = mute,
|
||||||
changeVolume(volume - 2000, false);
|
.locallyOnly = local,
|
||||||
});
|
});
|
||||||
}
|
});
|
||||||
|
const auto changeVolume = crl::guard(this, [=](
|
||||||
|
int volume,
|
||||||
|
bool local) {
|
||||||
|
_changeVolumeRequests.fire(Group::VolumeRequest{
|
||||||
|
.user = user,
|
||||||
|
.volume = std::clamp(volume, 1, Group::kMaxVolume),
|
||||||
|
.locallyOnly = local,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
{
|
|
||||||
const auto call = _call.get();
|
const auto call = _call.get();
|
||||||
auto otherParticipantStateValue = call
|
auto otherParticipantStateValue = call
|
||||||
? call->otherParticipantStateValue(
|
? call->otherParticipantStateValue(
|
||||||
|
@ -1270,23 +1245,27 @@ base::unique_qptr<Ui::PopupMenu> MembersController::createRowContextMenu(
|
||||||
})
|
})
|
||||||
: rpl::never<Group::ParticipantState>();
|
: rpl::never<Group::ParticipantState>();
|
||||||
|
|
||||||
|
const auto isMuted = (muteState == Row::State::Muted)
|
||||||
|
|| (muteState == Row::State::MutedByMe);
|
||||||
|
|
||||||
auto volumeItem = base::make_unique_q<MenuVolumeItem>(
|
auto volumeItem = base::make_unique_q<MenuVolumeItem>(
|
||||||
result,
|
result,
|
||||||
st::groupCallPopupMenu.menu,
|
st::groupCallPopupMenu.menu,
|
||||||
otherParticipantStateValue,
|
otherParticipantStateValue,
|
||||||
real->volume(),
|
real->volume(),
|
||||||
Group::kMaxVolume,
|
Group::kMaxVolume,
|
||||||
(muteState == Row::State::Muted
|
isMuted);
|
||||||
|| muteState == Row::State::MutedByMe));
|
|
||||||
|
auto mutesFromVolume = volumeItem->toggleMuteRequests();
|
||||||
|
|
||||||
volumeItem->toggleMuteRequests(
|
volumeItem->toggleMuteRequests(
|
||||||
) | rpl::start_with_next([=](bool muted) {
|
) | rpl::start_with_next([=](bool muted) {
|
||||||
toggleMute_(muted, false);
|
toggleMute(muted, false);
|
||||||
}, volumeItem->lifetime());
|
}, volumeItem->lifetime());
|
||||||
|
|
||||||
volumeItem->toggleMuteLocallyRequests(
|
volumeItem->toggleMuteLocallyRequests(
|
||||||
) | rpl::start_with_next([=](bool muted) {
|
) | rpl::start_with_next([=](bool muted) {
|
||||||
toggleMute_(muted, true);
|
toggleMute(muted, true);
|
||||||
}, volumeItem->lifetime());
|
}, volumeItem->lifetime());
|
||||||
|
|
||||||
volumeItem->changeVolumeRequests(
|
volumeItem->changeVolumeRequests(
|
||||||
|
@ -1300,8 +1279,31 @@ base::unique_qptr<Ui::PopupMenu> MembersController::createRowContextMenu(
|
||||||
}, volumeItem->lifetime());
|
}, volumeItem->lifetime());
|
||||||
|
|
||||||
result->addAction(std::move(volumeItem));
|
result->addAction(std::move(volumeItem));
|
||||||
|
|
||||||
|
const auto muteAction = [&]() -> QAction* {
|
||||||
|
if (muteState == Row::State::Invited) {
|
||||||
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
auto callback = [=] {
|
||||||
|
const auto state = real->state();
|
||||||
|
const auto muted = (state == Row::State::Muted)
|
||||||
|
|| (state == Row::State::MutedByMe);
|
||||||
|
toggleMute(!muted, false);
|
||||||
|
};
|
||||||
|
return result->addAction(
|
||||||
|
isMuted ? unmuteString() : muteString(),
|
||||||
|
std::move(callback));
|
||||||
|
}();
|
||||||
|
|
||||||
|
std::move(
|
||||||
|
mutesFromVolume
|
||||||
|
) | rpl::filter([=] {
|
||||||
|
return muteAction != nullptr;
|
||||||
|
}) | rpl::start_with_next([=](bool muted) {
|
||||||
|
muteAction->setText(muted ? unmuteString() : muteString());
|
||||||
|
}, result->lifetime());
|
||||||
}
|
}
|
||||||
|
|
||||||
result->addAction(
|
result->addAction(
|
||||||
tr::lng_context_view_profile(tr::now),
|
tr::lng_context_view_profile(tr::now),
|
||||||
showProfile);
|
showProfile);
|
||||||
|
|
Loading…
Add table
Reference in a new issue