From c2900db061d9f90d6b7c2a2c25ffe937ba74acef Mon Sep 17 00:00:00 2001 From: John Preston Date: Tue, 6 Apr 2021 18:08:37 +0400 Subject: [PATCH] Allow change join_as in scheduled call. --- .../SourceFiles/calls/calls_group_call.cpp | 24 +++++++++++++------ Telegram/SourceFiles/calls/calls_group_call.h | 1 + 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/Telegram/SourceFiles/calls/calls_group_call.cpp b/Telegram/SourceFiles/calls/calls_group_call.cpp index 361909e139..ef7346514c 100644 --- a/Telegram/SourceFiles/calls/calls_group_call.cpp +++ b/Telegram/SourceFiles/calls/calls_group_call.cpp @@ -457,6 +457,15 @@ void GroupCall::rejoinWithHash(const QString &hash) { } } +void GroupCall::setJoinAs(not_null as) { + _joinAs = as; + if (const auto chat = _peer->asChat()) { + chat->setGroupCallDefaultJoinAs(_joinAs->id); + } else if (const auto channel = _peer->asChannel()) { + channel->setGroupCallDefaultJoinAs(_joinAs->id); + } +} + void GroupCall::rejoin(not_null as) { if (state() != State::Joining && state() != State::Joined @@ -472,12 +481,7 @@ void GroupCall::rejoin(not_null as) { applyMeInCallLocally(); LOG(("Call Info: Requesting join payload.")); - _joinAs = as; - if (const auto chat = _peer->asChat()) { - chat->setGroupCallDefaultJoinAs(_joinAs->id); - } else if (const auto channel = _peer->asChannel()) { - channel->setGroupCallDefaultJoinAs(_joinAs->id); - } + setJoinAs(as); const auto weak = base::make_weak(this); _instance->emitJoinPayload([=](tgcalls::GroupJoinPayload payload) { @@ -691,7 +695,13 @@ void GroupCall::rejoinAs(Group::JoinInfo info) { .wasJoinAs = _joinAs, .nowJoinAs = info.joinAs, }; - if (!_scheduleDate) { + if (_scheduleDate) { + setJoinAs(info.joinAs); + _api.request(MTPphone_SaveDefaultGroupCallJoinAs( + _peer->input, + _joinAs->input + )).send(); + } else { setState(State::Joining); rejoin(info.joinAs); } diff --git a/Telegram/SourceFiles/calls/calls_group_call.h b/Telegram/SourceFiles/calls/calls_group_call.h index 9be926cdd3..b070e5cdb2 100644 --- a/Telegram/SourceFiles/calls/calls_group_call.h +++ b/Telegram/SourceFiles/calls/calls_group_call.h @@ -255,6 +255,7 @@ private: void applyMeInCallLocally(); void rejoin(); void rejoin(not_null as); + void setJoinAs(not_null as); void subscribeToReal(not_null real); void audioLevelsUpdated(const tgcalls::GroupLevelsUpdate &data);