Create voice chats with confirmation.

This commit is contained in:
John Preston 2020-12-09 16:24:25 +04:00
parent d15a5c9bdc
commit 7feb841081
3 changed files with 21 additions and 8 deletions

View File

@ -1826,6 +1826,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
"lng_group_call_leave_title" = "Leave voice chat";
"lng_group_call_leave_sure" = "Are you sure you want to leave this voice chat?";
"lng_group_call_leave_to_other_sure" = "Do you want to leave your active voice chat and join a voice chat in this group?";
"lng_group_call_create_sure" = "Do you really want to start a voice chat in this group?";
"lng_group_call_also_end" = "End voice chat";
"lng_group_call_settings_title" = "Settings";
"lng_group_call_invite_title" = "Invite members";
@ -1833,7 +1834,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
"lng_group_call_new_muted" = "Mute new members";
"lng_group_call_speakers" = "Speakers";
"lng_group_call_microphone" = "Microphone";
"lng_group_call_push_to_talk" = "Push to Talk";
"lng_group_call_push_to_talk" = "Push to Talk Shortcut";
"lng_group_call_ptt_shortcut" = "Edit Shortcut";
"lng_group_call_ptt_recording" = "Stop Recording";
"lng_group_call_ptt_delay_ms" = "{amount} ms";

View File

@ -223,10 +223,19 @@ void TopBarWidget::groupCall() {
if (const auto megagroup = peer->asMegagroup()) {
_controller->startOrJoinGroupCall(megagroup);
} else if (const auto chat = peer->asChat()) {
const auto start = [=](not_null<ChannelData*> megagroup) {
_controller->startOrJoinGroupCall(megagroup);
const auto callback = [=] {
Ui::hideLayer();
const auto start = [=](not_null<ChannelData*> megagroup) {
_controller->startOrJoinGroupCall(megagroup, true);
};
peer->session().api().migrateChat(
chat,
crl::guard(this, start));
};
peer->session().api().migrateChat(chat, crl::guard(this, start));
Ui::show(Box<ConfirmBox>(
tr::lng_group_call_create_sure(tr::now),
tr::lng_continue(tr::now),
crl::guard(this, callback)));
}
}
}
@ -655,11 +664,11 @@ void TopBarWidget::updateControlsGeometry() {
if (!_infoToggle->isHidden()) {
_rightTaken += _infoToggle->width() + st::topBarSkip;
}
_search->moveToRight(_rightTaken, otherButtonsTop);
_rightTaken += _search->width() + st::topBarCallSkip;
_call->moveToRight(_rightTaken, otherButtonsTop);
_groupCall->moveToRight(_rightTaken, otherButtonsTop);
_rightTaken += _call->width();
_search->moveToRight(_rightTaken, otherButtonsTop);
_rightTaken += _search->width() + st::topBarCallSkip;
updateMembersShowArea();
}
@ -717,8 +726,7 @@ void TopBarWidget::updateControlsVisibility() {
const auto callsEnabled = [&] {
if (const auto peer = _activeChat.key.peer()) {
if (const auto user = peer->asUser()) {
return session().serverConfig().phoneCallsEnabled.current()
&& user->hasCalls();
return true;
}
}
return false;

View File

@ -961,6 +961,10 @@ void SessionController::startOrJoinGroupCall(
tr::lng_group_call_leave_to_other_sure(tr::now),
tr::lng_group_call_leave(tr::now));
}
} else if (!confirmedLeaveOther && !megagroup->call()) {
confirm(
tr::lng_group_call_create_sure(tr::now),
tr::lng_continue(tr::now));
} else {
calls.startOrJoinGroupCall(megagroup);
}