Skip call ended sound if ended from other device.

This commit is contained in:
John Preston 2017-05-12 19:09:34 +03:00
parent 9dfd7f4ba9
commit 843f983051
3 changed files with 11 additions and 2 deletions

View file

@ -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;

View file

@ -91,6 +91,7 @@ public:
Failed,
HangingUp,
Ended,
EndedByOtherDevice,
ExchangingKeys,
Waiting,
Requesting,

View file

@ -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);