From 529c12ea3a2a4bdb9e0fe45e56f26162ebc7cc33 Mon Sep 17 00:00:00 2001 From: John Preston Date: Tue, 8 Dec 2020 16:03:59 +0400 Subject: [PATCH] Hide call panel when starting hanging up. --- Telegram/SourceFiles/calls/calls_group_panel.cpp | 10 ++++++++++ Telegram/SourceFiles/calls/calls_instance.cpp | 12 +++++++++++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/Telegram/SourceFiles/calls/calls_group_panel.cpp b/Telegram/SourceFiles/calls/calls_group_panel.cpp index 80339859d5..0c7c785402 100644 --- a/Telegram/SourceFiles/calls/calls_group_panel.cpp +++ b/Telegram/SourceFiles/calls/calls_group_panel.cpp @@ -353,6 +353,16 @@ void GroupPanel::initWithCall(GroupCall *call) { _channel = _call->channel(); + call->stateValue( + ) | rpl::filter([](State state) { + return (state == State::HangingUp) + || (state == State::Ended) + || (state == State::FailedHangingUp) + || (state == State::Failed); + }) | rpl::start_with_next([=] { + closeBeforeDestroy(); + }, _callLifetime); + call->levelUpdates( ) | rpl::filter([=](const LevelUpdate &update) { return update.self; diff --git a/Telegram/SourceFiles/calls/calls_instance.cpp b/Telegram/SourceFiles/calls/calls_instance.cpp index 38e3fb256e..f1c4058107 100644 --- a/Telegram/SourceFiles/calls/calls_instance.cpp +++ b/Telegram/SourceFiles/calls/calls_instance.cpp @@ -196,6 +196,9 @@ void Instance::destroyGroupCall(not_null call) { void Instance::createGroupCall( not_null channel, const MTPInputGroupCall &inputCall) { + if (_currentGroupCall) { + destroyGroupCall(_currentGroupCall.get()); + } auto call = std::make_unique( getGroupCallDelegate(), channel, @@ -433,7 +436,14 @@ bool Instance::inCall() const { } bool Instance::inGroupCall() const { - return (_currentGroupCall != nullptr); + if (!_currentGroupCall) { + return false; + } + const auto state = _currentGroupCall->state(); + return (state != GroupCall::State::HangingUp) + && (state != GroupCall::State::Ended) + && (state != GroupCall::State::FailedHangingUp) + && (state != GroupCall::State::Failed); } bool Instance::activateCurrentCall() {