2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-31 14:38:15 +00:00

Join other calls with confirmation.

This commit is contained in:
John Preston
2020-12-08 19:09:13 +04:00
parent 529c12ea3a
commit 546881c720
11 changed files with 119 additions and 58 deletions

View File

@@ -38,6 +38,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/text/text_utilities.h"
#include "ui/delayed_activation.h"
#include "ui/toast/toast.h"
#include "ui/toasts/common_toasts.h"
#include "calls/calls_instance.h" // Core::App().calls().inCall().
#include "boxes/calendar_box.h"
#include "boxes/confirm_box.h"
#include "mainwidget.h"
@@ -930,6 +932,40 @@ void SessionController::closeThirdSection() {
}
}
void SessionController::startOrJoinGroupCall(
not_null<ChannelData*> megagroup,
bool confirmedLeaveOther) {
if (megagroup->amAnonymous()) {
Ui::ShowMultilineToast({
.text = tr::lng_group_call_no_anonymous(tr::now),
});
return;
}
auto &calls = Core::App().calls();
const auto confirm = [&](QString text, QString button) {
Ui::show(Box<ConfirmBox>(text, button, crl::guard(this, [=] {
Ui::hideLayer();
startOrJoinGroupCall(megagroup, true);
})));
};
if (!confirmedLeaveOther && calls.inCall()) {
// Do you want to leave your active voice chat to join a voice chat in this group?
confirm(
tr::lng_call_leave_to_other_sure(tr::now),
tr::lng_call_bar_hangup(tr::now));
} else if (!confirmedLeaveOther && calls.inGroupCall()) {
if (calls.currentGroupCall()->channel() == megagroup) {
calls.activateCurrentCall();
} else {
confirm(
tr::lng_group_call_leave_to_other_sure(tr::now),
tr::lng_group_call_leave(tr::now));
}
} else {
calls.startOrJoinGroupCall(megagroup);
}
}
void SessionController::showJumpToDate(Dialogs::Key chat, QDate requestedDate) {
const auto currentPeerDate = [&] {
if (const auto history = chat.history()) {