Leave voice chat without confirmation.

This commit is contained in:
John Preston 2020-12-15 14:49:31 +04:00
parent b550eb5ab2
commit 703b21b4e5
3 changed files with 16 additions and 9 deletions

View file

@ -315,14 +315,17 @@ void GroupPanel::initWidget() {
}, widget()->lifetime()); }, widget()->lifetime());
} }
void GroupPanel::hangup(bool discardCallChecked) { void GroupPanel::endCall() {
if (!_call) { if (!_call) {
return; return;
} else if (!_call->peer()->canManageGroupCall()) {
_call->hangup();
return;
} }
_layerBg->showBox(Box( _layerBg->showBox(Box(
LeaveGroupCallBox, LeaveGroupCallBox,
_call, _call,
discardCallChecked, false,
BoxContext::GroupCallPanel)); BoxContext::GroupCallPanel));
} }
@ -338,7 +341,7 @@ void GroupPanel::initControls() {
: MuteState::Muted); : MuteState::Muted);
}, _mute->lifetime()); }, _mute->lifetime());
_hangup->setClickedCallback([=] { hangup(false); }); _hangup->setClickedCallback([=] { endCall(); });
_settings->setClickedCallback([=] { _settings->setClickedCallback([=] {
if (_call) { if (_call) {
_layerBg->showBox(Box(GroupCallSettingsBox, _call)); _layerBg->showBox(Box(GroupCallSettingsBox, _call));

View file

@ -90,7 +90,7 @@ private:
void updateControlsGeometry(); void updateControlsGeometry();
void showControls(); void showControls();
void hangup(bool discardCallChecked); void endCall();
void addMembers(); void addMembers();
void kickMember(not_null<UserData*> user); void kickMember(not_null<UserData*> user);

View file

@ -337,11 +337,15 @@ void TopBar::initControls() {
if (const auto call = _call.get()) { if (const auto call = _call.get()) {
call->hangup(); call->hangup();
} else if (const auto group = _groupCall.get()) { } else if (const auto group = _groupCall.get()) {
Ui::show(Box( if (!group->peer()->canManageGroupCall()) {
LeaveGroupCallBox, group->hangup();
group, } else {
false, Ui::show(Box(
BoxContext::MainWindow)); LeaveGroupCallBox,
group,
false,
BoxContext::MainWindow));
}
} }
}); });
updateDurationText(); updateDurationText();