2
0
mirror of https://github.com/kotatogram/kotatogram-desktop synced 2025-08-31 06:35:14 +00:00

Allow to rejoin with changing of 'join_as'.

This commit is contained in:
John Preston
2021-03-05 19:21:11 +04:00
parent 4d093f78e2
commit b670ca2a51
13 changed files with 235 additions and 123 deletions

View File

@@ -7,6 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#include "calls/calls_instance.h"
#include "calls/calls_group_common.h"
#include "mtproto/mtproto_dh_utils.h"
#include "core/application.h"
#include "main/main_session.h"
@@ -61,27 +62,18 @@ void Instance::startOutgoingCall(not_null<UserData*> user, bool video) {
void Instance::startOrJoinGroupCall(not_null<PeerData*> peer) {
const auto context = peer->groupCall()
? ChooseJoinAsProcess::Context::Join
: ChooseJoinAsProcess::Context::Create;
_chooseJoinAs.start(peer, context, [=](
not_null<PeerData*> peer,
not_null<PeerData*> joinAs) {
startOrJoinGroupCall(peer, joinAs);
? Group::ChooseJoinAsProcess::Context::Join
: Group::ChooseJoinAsProcess::Context::Create;
_chooseJoinAs.start(peer, context, [=](object_ptr<Ui::BoxContent> box) {
Ui::show(std::move(box), Ui::LayerOption::KeepOther);
}, [=](Group::JoinInfo info) {
const auto call = info.peer->groupCall();
createGroupCall(
std::move(info),
call ? call->input() : MTP_inputGroupCall(MTPlong(), MTPlong()));
});
}
void Instance::startOrJoinGroupCall(
not_null<PeerData*> peer,
not_null<PeerData*> joinAs) {
destroyCurrentCall();
const auto call = peer->groupCall();
createGroupCall(
peer,
call ? call->input() : MTP_inputGroupCall(MTPlong(), MTPlong()),
joinAs);
}
void Instance::callFinished(not_null<Call*> call) {
crl::on_main(call, [=] {
destroyCall(call);
@@ -208,19 +200,17 @@ void Instance::destroyGroupCall(not_null<GroupCall*> call) {
}
void Instance::createGroupCall(
not_null<PeerData*> peer,
const MTPInputGroupCall &inputCall,
not_null<PeerData*> joinAs) {
Group::JoinInfo info,
const MTPInputGroupCall &inputCall) {
destroyCurrentCall();
auto call = std::make_unique<GroupCall>(
getGroupCallDelegate(),
peer,
inputCall,
joinAs);
std::move(info),
inputCall);
const auto raw = call.get();
peer->session().account().sessionChanges(
info.peer->session().account().sessionChanges(
) | rpl::start_with_next([=] {
destroyGroupCall(raw);
}, raw->lifetime());