2021-03-05 08:14:34 +00:00
|
|
|
/*
|
|
|
|
This file is part of Telegram Desktop,
|
|
|
|
the official desktop application for the Telegram messaging service.
|
|
|
|
|
|
|
|
For license and copyright information please follow this link:
|
|
|
|
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|
|
|
*/
|
2021-04-22 09:13:13 +00:00
|
|
|
#include "calls/group/calls_choose_join_as.h"
|
2021-03-05 08:14:34 +00:00
|
|
|
|
2021-04-22 09:13:13 +00:00
|
|
|
#include "calls/group/calls_group_common.h"
|
|
|
|
#include "calls/group/calls_group_menu.h"
|
2021-03-05 08:14:34 +00:00
|
|
|
#include "data/data_peer.h"
|
|
|
|
#include "data/data_user.h"
|
|
|
|
#include "data/data_channel.h"
|
|
|
|
#include "data/data_session.h"
|
2021-03-16 13:16:01 +00:00
|
|
|
#include "data/data_group_call.h"
|
2021-03-05 08:14:34 +00:00
|
|
|
#include "main/main_session.h"
|
|
|
|
#include "main/main_account.h"
|
|
|
|
#include "lang/lang_keys.h"
|
|
|
|
#include "apiwrap.h"
|
|
|
|
#include "ui/layers/generic_box.h"
|
2021-04-05 10:29:03 +00:00
|
|
|
#include "ui/boxes/choose_date_time.h"
|
2021-03-16 13:16:01 +00:00
|
|
|
#include "ui/text/text_utilities.h"
|
2021-03-05 08:14:34 +00:00
|
|
|
#include "boxes/peer_list_box.h"
|
2021-04-05 10:29:03 +00:00
|
|
|
#include "base/unixtime.h"
|
|
|
|
#include "base/timer_rpl.h"
|
2021-03-05 08:14:34 +00:00
|
|
|
#include "styles/style_boxes.h"
|
2021-04-07 07:21:59 +00:00
|
|
|
#include "styles/style_layers.h"
|
2021-03-05 15:21:11 +00:00
|
|
|
#include "styles/style_calls.h"
|
2021-03-05 08:14:34 +00:00
|
|
|
|
2021-03-05 15:21:11 +00:00
|
|
|
namespace Calls::Group {
|
2021-03-05 08:14:34 +00:00
|
|
|
namespace {
|
|
|
|
|
2021-04-05 10:29:03 +00:00
|
|
|
constexpr auto kLabelRefreshInterval = 10 * crl::time(1000);
|
|
|
|
|
2021-03-05 08:14:34 +00:00
|
|
|
using Context = ChooseJoinAsProcess::Context;
|
|
|
|
|
|
|
|
class ListController : public PeerListController {
|
|
|
|
public:
|
|
|
|
ListController(
|
|
|
|
std::vector<not_null<PeerData*>> list,
|
|
|
|
not_null<PeerData*> selected);
|
|
|
|
|
|
|
|
Main::Session &session() const override;
|
|
|
|
void prepare() override;
|
|
|
|
void rowClicked(not_null<PeerListRow*> row) override;
|
|
|
|
|
|
|
|
[[nodiscard]] not_null<PeerData*> selected() const;
|
|
|
|
|
|
|
|
private:
|
|
|
|
std::unique_ptr<PeerListRow> createRow(not_null<PeerData*> peer);
|
|
|
|
|
|
|
|
std::vector<not_null<PeerData*>> _list;
|
|
|
|
not_null<PeerData*> _selected;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
ListController::ListController(
|
|
|
|
std::vector<not_null<PeerData*>> list,
|
|
|
|
not_null<PeerData*> selected)
|
|
|
|
: PeerListController()
|
|
|
|
, _list(std::move(list))
|
|
|
|
, _selected(selected) {
|
|
|
|
}
|
|
|
|
|
|
|
|
Main::Session &ListController::session() const {
|
|
|
|
return _selected->session();
|
|
|
|
}
|
|
|
|
|
|
|
|
std::unique_ptr<PeerListRow> ListController::createRow(
|
|
|
|
not_null<PeerData*> peer) {
|
|
|
|
auto result = std::make_unique<PeerListRow>(peer);
|
|
|
|
if (peer->isSelf()) {
|
|
|
|
result->setCustomStatus(
|
|
|
|
tr::lng_group_call_join_as_personal(tr::now));
|
|
|
|
} else if (const auto channel = peer->asChannel()) {
|
|
|
|
result->setCustomStatus(
|
|
|
|
(channel->isMegagroup()
|
|
|
|
? tr::lng_chat_status_members
|
|
|
|
: tr::lng_chat_status_subscribers)(
|
|
|
|
tr::now,
|
|
|
|
lt_count,
|
|
|
|
channel->membersCount()));
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ListController::prepare() {
|
|
|
|
delegate()->peerListSetSearchMode(PeerListSearchMode::Disabled);
|
|
|
|
for (const auto &peer : _list) {
|
|
|
|
auto row = createRow(peer);
|
|
|
|
const auto raw = row.get();
|
|
|
|
delegate()->peerListAppendRow(std::move(row));
|
|
|
|
if (peer == _selected) {
|
|
|
|
delegate()->peerListSetRowChecked(raw, true);
|
2021-03-05 11:36:07 +00:00
|
|
|
raw->finishCheckedAnimation();
|
2021-03-05 08:14:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
delegate()->peerListRefreshRows();
|
|
|
|
}
|
|
|
|
|
|
|
|
void ListController::rowClicked(not_null<PeerListRow*> row) {
|
|
|
|
const auto peer = row->peer();
|
|
|
|
if (peer == _selected) {
|
|
|
|
return;
|
|
|
|
}
|
2021-04-01 21:04:10 +00:00
|
|
|
const auto previous = delegate()->peerListFindRow(_selected->id.value);
|
2021-03-05 08:14:34 +00:00
|
|
|
Assert(previous != nullptr);
|
|
|
|
delegate()->peerListSetRowChecked(previous, false);
|
|
|
|
delegate()->peerListSetRowChecked(row, true);
|
|
|
|
_selected = peer;
|
|
|
|
}
|
|
|
|
|
|
|
|
not_null<PeerData*> ListController::selected() const {
|
|
|
|
return _selected;
|
|
|
|
}
|
|
|
|
|
2021-04-05 10:29:03 +00:00
|
|
|
void ScheduleGroupCallBox(
|
|
|
|
not_null<Ui::GenericBox*> box,
|
|
|
|
const JoinInfo &info,
|
|
|
|
Fn<void(JoinInfo)> done) {
|
|
|
|
const auto send = [=](TimeId date) {
|
|
|
|
box->closeBox();
|
|
|
|
|
|
|
|
auto copy = info;
|
|
|
|
copy.scheduleDate = date;
|
|
|
|
done(std::move(copy));
|
|
|
|
};
|
|
|
|
const auto duration = box->lifetime().make_state<
|
|
|
|
rpl::variable<QString>>();
|
|
|
|
auto description = (info.peer->isBroadcast()
|
|
|
|
? tr::lng_group_call_schedule_notified_channel
|
|
|
|
: tr::lng_group_call_schedule_notified_group)(
|
|
|
|
lt_duration,
|
|
|
|
duration->value());
|
2021-04-09 13:59:43 +00:00
|
|
|
|
|
|
|
const auto now = QDateTime::currentDateTime();
|
|
|
|
const auto min = [] {
|
|
|
|
return base::unixtime::serialize(
|
|
|
|
QDateTime::currentDateTime().addSecs(12));
|
|
|
|
};
|
|
|
|
const auto max = [] {
|
|
|
|
return base::unixtime::serialize(
|
2021-04-09 15:17:47 +00:00
|
|
|
QDateTime(QDate::currentDate().addDays(8), QTime(0, 0))) - 1;
|
2021-04-09 13:59:43 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// At least half an hour later, at zero minutes/seconds.
|
|
|
|
const auto schedule = QDateTime(
|
|
|
|
now.date(),
|
|
|
|
QTime(now.time().hour(), 0)
|
|
|
|
).addSecs(60 * 60 * (now.time().minute() < 30 ? 1 : 2));
|
|
|
|
|
|
|
|
auto descriptor = Ui::ChooseDateTimeBox(box, {
|
|
|
|
.title = tr::lng_group_call_schedule_title(),
|
|
|
|
.submit = tr::lng_schedule_button(),
|
|
|
|
.done = send,
|
|
|
|
.min = min,
|
|
|
|
.time = base::unixtime::serialize(schedule),
|
|
|
|
.max = max,
|
|
|
|
.description = std::move(description),
|
|
|
|
});
|
2021-04-05 10:29:03 +00:00
|
|
|
|
|
|
|
using namespace rpl::mappers;
|
|
|
|
*duration = rpl::combine(
|
|
|
|
rpl::single(
|
|
|
|
rpl::empty_value()
|
|
|
|
) | rpl::then(base::timer_each(kLabelRefreshInterval)),
|
|
|
|
std::move(descriptor.values) | rpl::filter(_1 != 0),
|
|
|
|
_2
|
|
|
|
) | rpl::map([](TimeId date) {
|
|
|
|
const auto now = base::unixtime::now();
|
|
|
|
const auto duration = (date - now);
|
|
|
|
if (duration >= 24 * 60 * 60) {
|
2021-04-06 09:59:14 +00:00
|
|
|
return tr::lng_group_call_duration_days(
|
2021-04-05 10:29:03 +00:00
|
|
|
tr::now,
|
|
|
|
lt_count,
|
|
|
|
duration / (24 * 60 * 60));
|
|
|
|
} else if (duration >= 60 * 60) {
|
2021-04-06 09:59:14 +00:00
|
|
|
return tr::lng_group_call_duration_hours(
|
2021-04-05 10:29:03 +00:00
|
|
|
tr::now,
|
|
|
|
lt_count,
|
|
|
|
duration / (60 * 60));
|
|
|
|
}
|
2021-04-06 09:59:14 +00:00
|
|
|
return tr::lng_group_call_duration_minutes(
|
2021-04-05 10:29:03 +00:00
|
|
|
tr::now,
|
|
|
|
lt_count,
|
|
|
|
std::max(duration / 60, 1));
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2021-03-05 08:14:34 +00:00
|
|
|
void ChooseJoinAsBox(
|
|
|
|
not_null<Ui::GenericBox*> box,
|
|
|
|
Context context,
|
2021-03-05 15:21:11 +00:00
|
|
|
JoinInfo info,
|
|
|
|
Fn<void(JoinInfo)> done) {
|
2021-03-16 13:16:52 +00:00
|
|
|
box->setWidth(st::groupCallJoinAsWidth);
|
2021-03-05 08:14:34 +00:00
|
|
|
box->setTitle([&] {
|
|
|
|
switch (context) {
|
|
|
|
case Context::Create: return tr::lng_group_call_start_as_header();
|
2021-03-16 13:16:01 +00:00
|
|
|
case Context::Join:
|
|
|
|
case Context::JoinWithConfirm: return tr::lng_group_call_join_as_header();
|
2021-03-05 08:14:34 +00:00
|
|
|
case Context::Switch: return tr::lng_group_call_display_as_header();
|
|
|
|
}
|
|
|
|
Unexpected("Context in ChooseJoinAsBox.");
|
|
|
|
}());
|
2021-04-05 10:29:03 +00:00
|
|
|
const auto &labelSt = (context == Context::Switch)
|
|
|
|
? st::groupCallJoinAsLabel
|
|
|
|
: st::confirmPhoneAboutLabel;
|
2021-03-05 08:14:34 +00:00
|
|
|
box->addRow(object_ptr<Ui::FlatLabel>(
|
|
|
|
box,
|
|
|
|
tr::lng_group_call_join_as_about(),
|
2021-04-05 10:29:03 +00:00
|
|
|
labelSt));
|
2021-03-05 08:14:34 +00:00
|
|
|
|
|
|
|
auto &lifetime = box->lifetime();
|
|
|
|
const auto delegate = lifetime.make_state<
|
|
|
|
PeerListContentDelegateSimple
|
|
|
|
>();
|
|
|
|
const auto controller = lifetime.make_state<ListController>(
|
2021-03-05 15:21:11 +00:00
|
|
|
info.possibleJoinAs,
|
|
|
|
info.joinAs);
|
|
|
|
if (context == Context::Switch) {
|
|
|
|
controller->setStyleOverrides(
|
2021-03-10 11:55:00 +00:00
|
|
|
&st::groupCallJoinAsList,
|
2021-03-05 15:21:11 +00:00
|
|
|
&st::groupCallMultiSelect);
|
2021-03-10 11:55:00 +00:00
|
|
|
} else {
|
|
|
|
controller->setStyleOverrides(
|
|
|
|
&st::peerListJoinAsList,
|
|
|
|
nullptr);
|
2021-03-05 15:21:11 +00:00
|
|
|
}
|
2021-03-05 08:14:34 +00:00
|
|
|
const auto content = box->addRow(
|
|
|
|
object_ptr<PeerListContent>(box, controller),
|
|
|
|
style::margins());
|
|
|
|
delegate->setContent(content);
|
|
|
|
controller->setDelegate(delegate);
|
2021-03-10 12:29:09 +00:00
|
|
|
auto next = (context == Context::Switch)
|
|
|
|
? tr::lng_settings_save()
|
|
|
|
: tr::lng_continue();
|
2021-04-05 10:29:03 +00:00
|
|
|
if (context == Context::Create) {
|
|
|
|
const auto makeLink = [](const QString &text) {
|
|
|
|
return Ui::Text::Link(text);
|
|
|
|
};
|
|
|
|
const auto label = box->addRow(object_ptr<Ui::FlatLabel>(
|
|
|
|
box,
|
|
|
|
tr::lng_group_call_or_schedule(
|
|
|
|
lt_link,
|
|
|
|
tr::lng_group_call_schedule(makeLink),
|
|
|
|
Ui::Text::WithEntities),
|
|
|
|
labelSt));
|
|
|
|
label->setClickHandlerFilter([=](const auto&...) {
|
|
|
|
auto withJoinAs = info;
|
|
|
|
withJoinAs.joinAs = controller->selected();
|
2021-04-07 07:21:59 +00:00
|
|
|
box->getDelegate()->show(
|
|
|
|
Box(ScheduleGroupCallBox, withJoinAs, done));
|
2021-04-05 10:29:03 +00:00
|
|
|
return false;
|
|
|
|
});
|
|
|
|
}
|
2021-03-10 12:29:09 +00:00
|
|
|
box->addButton(std::move(next), [=] {
|
2021-03-05 15:21:11 +00:00
|
|
|
auto copy = info;
|
|
|
|
copy.joinAs = controller->selected();
|
|
|
|
done(std::move(copy));
|
2021-03-05 08:14:34 +00:00
|
|
|
});
|
|
|
|
box->addButton(tr::lng_cancel(), [=] { box->closeBox(); });
|
|
|
|
}
|
|
|
|
|
2021-03-19 09:59:35 +00:00
|
|
|
[[nodiscard]] TextWithEntities CreateOrJoinConfirmation(
|
|
|
|
not_null<PeerData*> peer,
|
|
|
|
ChooseJoinAsProcess::Context context,
|
|
|
|
bool joinAsAlreadyUsed) {
|
|
|
|
const auto existing = peer->groupCall();
|
|
|
|
if (!existing) {
|
|
|
|
return { peer->isBroadcast()
|
|
|
|
? tr::lng_group_call_create_sure_channel(tr::now)
|
|
|
|
: tr::lng_group_call_create_sure(tr::now) };
|
|
|
|
}
|
|
|
|
const auto channel = peer->asChannel();
|
|
|
|
const auto anonymouseAdmin = channel
|
|
|
|
&& ((channel->isMegagroup() && channel->amAnonymous())
|
|
|
|
|| (channel->isBroadcast()
|
|
|
|
&& (channel->amCreator()
|
|
|
|
|| channel->hasAdminRights())));
|
|
|
|
if (anonymouseAdmin && !joinAsAlreadyUsed) {
|
|
|
|
return { tr::lng_group_call_join_sure_personal(tr::now) };
|
|
|
|
} else if (context != ChooseJoinAsProcess::Context::JoinWithConfirm) {
|
|
|
|
return {};
|
|
|
|
}
|
|
|
|
const auto name = !existing->title().isEmpty()
|
|
|
|
? existing->title()
|
|
|
|
: peer->name;
|
|
|
|
return tr::lng_group_call_join_confirm(
|
|
|
|
tr::now,
|
|
|
|
lt_chat,
|
|
|
|
Ui::Text::Bold(name),
|
|
|
|
Ui::Text::WithEntities);
|
|
|
|
}
|
|
|
|
|
2021-03-05 08:14:34 +00:00
|
|
|
} // namespace
|
|
|
|
|
|
|
|
ChooseJoinAsProcess::~ChooseJoinAsProcess() {
|
|
|
|
if (_request) {
|
|
|
|
_request->peer->session().api().request(_request->id).cancel();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void ChooseJoinAsProcess::start(
|
|
|
|
not_null<PeerData*> peer,
|
|
|
|
Context context,
|
2021-03-05 15:21:11 +00:00
|
|
|
Fn<void(object_ptr<Ui::BoxContent>)> showBox,
|
2021-03-08 08:49:07 +00:00
|
|
|
Fn<void(QString)> showToast,
|
2021-03-05 15:21:11 +00:00
|
|
|
Fn<void(JoinInfo)> done,
|
2021-03-16 10:32:52 +00:00
|
|
|
PeerData *changingJoinAsFrom) {
|
2021-03-05 08:14:34 +00:00
|
|
|
Expects(done != nullptr);
|
|
|
|
|
|
|
|
const auto session = &peer->session();
|
|
|
|
if (_request) {
|
2021-03-08 08:49:07 +00:00
|
|
|
if (_request->peer == peer) {
|
|
|
|
_request->context = context;
|
|
|
|
_request->showBox = std::move(showBox);
|
|
|
|
_request->showToast = std::move(showToast);
|
|
|
|
_request->done = std::move(done);
|
2021-03-05 08:14:34 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
session->api().request(_request->id).cancel();
|
|
|
|
_request = nullptr;
|
|
|
|
}
|
|
|
|
_request = std::make_unique<ChannelsListRequest>(
|
|
|
|
ChannelsListRequest{
|
|
|
|
.peer = peer,
|
2021-03-05 15:21:11 +00:00
|
|
|
.showBox = std::move(showBox),
|
2021-03-08 08:49:07 +00:00
|
|
|
.showToast = std::move(showToast),
|
2021-03-05 08:14:34 +00:00
|
|
|
.done = std::move(done),
|
|
|
|
.context = context });
|
|
|
|
session->account().sessionChanges(
|
|
|
|
) | rpl::start_with_next([=] {
|
|
|
|
_request = nullptr;
|
|
|
|
}, _request->lifetime);
|
|
|
|
|
2021-03-05 15:21:11 +00:00
|
|
|
const auto finish = [=](JoinInfo info) {
|
2021-03-05 08:14:34 +00:00
|
|
|
const auto done = std::move(_request->done);
|
2021-03-05 11:36:07 +00:00
|
|
|
const auto box = _request->box;
|
2021-03-05 08:14:34 +00:00
|
|
|
_request = nullptr;
|
2021-03-05 15:21:11 +00:00
|
|
|
done(std::move(info));
|
2021-03-05 11:36:07 +00:00
|
|
|
if (const auto strong = box.data()) {
|
|
|
|
strong->closeBox();
|
|
|
|
}
|
2021-03-05 08:14:34 +00:00
|
|
|
};
|
2021-03-08 08:49:07 +00:00
|
|
|
_request->id = session->api().request(MTPphone_GetGroupCallJoinAs(
|
|
|
|
_request->peer->input
|
|
|
|
)).done([=](const MTPphone_JoinAsPeers &result) {
|
2021-03-05 08:14:34 +00:00
|
|
|
const auto peer = _request->peer;
|
|
|
|
const auto self = peer->session().user();
|
2021-03-05 15:21:11 +00:00
|
|
|
auto info = JoinInfo{ .peer = peer, .joinAs = self };
|
2021-03-08 08:49:07 +00:00
|
|
|
auto list = result.match([&](const MTPDphone_joinAsPeers &data) {
|
|
|
|
session->data().processUsers(data.vusers());
|
|
|
|
session->data().processChats(data.vchats());
|
|
|
|
const auto &peers = data.vpeers().v;
|
|
|
|
auto list = std::vector<not_null<PeerData*>>();
|
|
|
|
list.reserve(peers.size());
|
|
|
|
for (const auto &peer : peers) {
|
|
|
|
const auto peerId = peerFromMTP(peer);
|
|
|
|
if (const auto peer = session->data().peerLoaded(peerId)) {
|
|
|
|
if (!ranges::contains(list, not_null{ peer })) {
|
|
|
|
list.push_back(peer);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return list;
|
|
|
|
});
|
2021-03-16 13:16:01 +00:00
|
|
|
const auto selectedId = peer->groupCallDefaultJoinAs();
|
2021-03-08 08:49:07 +00:00
|
|
|
if (list.empty()) {
|
2021-03-10 12:29:09 +00:00
|
|
|
_request->showToast(Lang::Hard::ServerError());
|
2021-03-08 08:49:07 +00:00
|
|
|
return;
|
2021-03-16 17:06:36 +00:00
|
|
|
}
|
|
|
|
info.joinAs = [&]() -> not_null<PeerData*> {
|
|
|
|
const auto loaded = selectedId
|
|
|
|
? session->data().peerLoaded(selectedId)
|
|
|
|
: nullptr;
|
|
|
|
return (changingJoinAsFrom
|
|
|
|
&& ranges::contains(list, not_null{ changingJoinAsFrom }))
|
|
|
|
? not_null(changingJoinAsFrom)
|
|
|
|
: (loaded && ranges::contains(list, not_null{ loaded }))
|
|
|
|
? not_null(loaded)
|
|
|
|
: ranges::contains(list, self)
|
|
|
|
? self
|
|
|
|
: list.front();
|
|
|
|
}();
|
|
|
|
info.possibleJoinAs = std::move(list);
|
|
|
|
|
|
|
|
const auto onlyByMe = (info.possibleJoinAs.size() == 1)
|
2021-03-19 09:59:35 +00:00
|
|
|
&& (info.possibleJoinAs.front() == self);
|
2021-03-16 17:06:36 +00:00
|
|
|
|
|
|
|
// We already joined this voice chat, just rejoin with the same.
|
|
|
|
const auto byAlreadyUsed = selectedId
|
2021-03-19 09:59:35 +00:00
|
|
|
&& (info.joinAs->id == selectedId)
|
|
|
|
&& (peer->groupCall() != nullptr);
|
2021-03-16 17:06:36 +00:00
|
|
|
|
|
|
|
if (!changingJoinAsFrom && (onlyByMe || byAlreadyUsed)) {
|
2021-04-07 07:21:59 +00:00
|
|
|
auto confirmation = CreateOrJoinConfirmation(
|
2021-03-19 09:59:35 +00:00
|
|
|
peer,
|
|
|
|
context,
|
|
|
|
byAlreadyUsed);
|
|
|
|
if (confirmation.text.isEmpty()) {
|
2021-03-16 13:16:01 +00:00
|
|
|
finish(info);
|
|
|
|
return;
|
|
|
|
}
|
2021-04-07 07:21:59 +00:00
|
|
|
const auto creating = !peer->groupCall();
|
|
|
|
if (creating) {
|
|
|
|
confirmation
|
|
|
|
.append("\n\n")
|
|
|
|
.append(tr::lng_group_call_or_schedule(
|
|
|
|
tr::now,
|
|
|
|
lt_link,
|
|
|
|
Ui::Text::Link(tr::lng_group_call_schedule(tr::now)),
|
|
|
|
Ui::Text::WithEntities));
|
|
|
|
}
|
|
|
|
const auto guard = base::make_weak(&_request->guard);
|
|
|
|
const auto safeFinish = crl::guard(guard, [=] { finish(info); });
|
|
|
|
const auto filter = [=](const auto &...) {
|
|
|
|
if (guard) {
|
|
|
|
_request->showBox(Box(
|
|
|
|
ScheduleGroupCallBox,
|
|
|
|
info,
|
|
|
|
crl::guard(guard, finish)));
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
};
|
|
|
|
auto box = ConfirmBox({
|
|
|
|
.text = confirmation,
|
|
|
|
.button = (creating
|
|
|
|
? tr::lng_create_group_create()
|
|
|
|
: tr::lng_group_call_join()),
|
|
|
|
.callback = crl::guard(guard, [=] { finish(info); }),
|
|
|
|
.st = &st::boxLabel,
|
|
|
|
.filter = filter,
|
|
|
|
});
|
2021-03-16 13:16:01 +00:00
|
|
|
box->boxClosing(
|
|
|
|
) | rpl::start_with_next([=] {
|
|
|
|
_request = nullptr;
|
|
|
|
}, _request->lifetime);
|
|
|
|
|
|
|
|
_request->box = box.data();
|
|
|
|
_request->showBox(std::move(box));
|
2021-03-05 08:14:34 +00:00
|
|
|
return;
|
|
|
|
}
|
2021-03-05 15:21:11 +00:00
|
|
|
auto box = Box(
|
|
|
|
ChooseJoinAsBox,
|
|
|
|
context,
|
|
|
|
std::move(info),
|
|
|
|
crl::guard(&_request->guard, finish));
|
|
|
|
box->boxClosing(
|
2021-03-05 11:36:07 +00:00
|
|
|
) | rpl::start_with_next([=] {
|
|
|
|
_request = nullptr;
|
|
|
|
}, _request->lifetime);
|
2021-03-05 15:21:11 +00:00
|
|
|
|
|
|
|
_request->box = box.data();
|
|
|
|
_request->showBox(std::move(box));
|
2021-03-12 12:48:00 +00:00
|
|
|
}).fail([=](const MTP::Error &error) {
|
2021-03-05 15:21:11 +00:00
|
|
|
finish({
|
|
|
|
.peer = _request->peer,
|
|
|
|
.joinAs = _request->peer->session().user(),
|
|
|
|
});
|
2021-03-05 08:14:34 +00:00
|
|
|
}).send();
|
|
|
|
}
|
|
|
|
|
2021-03-05 15:21:11 +00:00
|
|
|
} // namespace Calls::Group
|