From 843f9830517e9614ba4943bfeba8e90f9a6bd10b Mon Sep 17 00:00:00 2001 From: John Preston Date: Fri, 12 May 2017 19:09:34 +0300 Subject: [PATCH] Skip call ended sound if ended from other device. --- Telegram/SourceFiles/calls/calls_call.cpp | 8 +++++++- Telegram/SourceFiles/calls/calls_call.h | 1 + Telegram/SourceFiles/calls/calls_panel.cpp | 4 +++- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/Telegram/SourceFiles/calls/calls_call.cpp b/Telegram/SourceFiles/calls/calls_call.cpp index 3db28846d..3877a6988 100644 --- a/Telegram/SourceFiles/calls/calls_call.cpp +++ b/Telegram/SourceFiles/calls/calls_call.cpp @@ -364,8 +364,10 @@ bool Call::handleUpdate(const MTPPhoneCall &call) { } if (data.has_reason() && data.vreason.type() == mtpc_phoneCallDiscardReasonBusy) { setState(State::Busy); - } else { + } else if (_type == Type::Outgoing || _state == State::HangingUp) { setState(State::Ended); + } else { + setState(State::EndedByOtherDevice); } } return true; @@ -579,6 +581,7 @@ void Call::setState(State state) { } if (false || _state == State::Ended + || _state == State::EndedByOtherDevice || _state == State::Failed || _state == State::Busy) { // Destroy controller before destroying Call Panel, @@ -594,6 +597,8 @@ void Call::setState(State state) { break; case State::Ended: _delegate->playSound(Delegate::Sound::Ended); + // fallthrough + case State::EndedByOtherDevice: _delegate->callFinished(this); break; case State::Failed: @@ -618,6 +623,7 @@ void Call::finish(FinishType type, const MTPPhoneCallDiscardReason &reason) { } if (_state == State::HangingUp || _state == State::FailedHangingUp + || _state == State::EndedByOtherDevice || _state == State::Ended || _state == State::Failed) { return; diff --git a/Telegram/SourceFiles/calls/calls_call.h b/Telegram/SourceFiles/calls/calls_call.h index 958421e11..e5b8bc30e 100644 --- a/Telegram/SourceFiles/calls/calls_call.h +++ b/Telegram/SourceFiles/calls/calls_call.h @@ -91,6 +91,7 @@ public: Failed, HangingUp, Ended, + EndedByOtherDevice, ExchangingKeys, Waiting, Requesting, diff --git a/Telegram/SourceFiles/calls/calls_panel.cpp b/Telegram/SourceFiles/calls/calls_panel.cpp index a8a09da95..6096b8d15 100644 --- a/Telegram/SourceFiles/calls/calls_panel.cpp +++ b/Telegram/SourceFiles/calls/calls_panel.cpp @@ -710,6 +710,7 @@ void Panel::stateChanged(State state) { if (_call) { if ((state != State::HangingUp) && (state != State::Ended) + && (state != State::EndedByOtherDevice) && (state != State::FailedHangingUp) && (state != State::Failed)) { auto toggleButton = [this](auto &&button, bool visible) { @@ -785,7 +786,8 @@ void Panel::updateStatusText(State state) { case State::FailedHangingUp: case State::Failed: return lang(lng_call_status_failed); case State::HangingUp: return lang(lng_call_status_hanging); - case State::Ended: return lang(lng_call_status_ended); + case State::Ended: + case State::EndedByOtherDevice: return lang(lng_call_status_ended); case State::ExchangingKeys: return lang(lng_call_status_exchanging); case State::Waiting: return lang(lng_call_status_waiting); case State::Requesting: return lang(lng_call_status_requesting);