diff --git a/Telegram/SourceFiles/calls/calls_group_panel.cpp b/Telegram/SourceFiles/calls/calls_group_panel.cpp index 80339859d..0c7c78540 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 38e3fb256..f1c405810 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() {