Don't decline awaited incoming call on app quit.

This commit is contained in:
John Preston 2017-05-08 12:26:43 +03:00
parent 530a385d4e
commit e7dcd5ab15
4 changed files with 13 additions and 5 deletions

View File

@ -106,6 +106,13 @@ void Call::generateModExpFirst(base::const_byte_span randomSeed) {
}
}
bool Call::isIncomingWaiting() const {
if (type() != Call::Type::Incoming) {
return false;
}
return (_state == State::Starting) || (_state == State::WaitingIncoming);
}
void Call::start(base::const_byte_span random) {
// Save config here, because it is possible that it changes between
// different usages inside the same call.

View File

@ -77,6 +77,7 @@ public:
gsl::not_null<UserData*> user() const {
return _user;
}
bool isIncomingWaiting() const;
void start(base::const_byte_span random);
bool handleUpdate(const MTPPhoneCall &call);

View File

@ -253,7 +253,7 @@ void Instance::showInfoPanel(gsl::not_null<Call*> call) {
}
bool Instance::isQuitPrevent() {
if (!_currentCall) {
if (!_currentCall || _currentCall->isIncomingWaiting()) {
return false;
}
_currentCall->hangup();

View File

@ -318,7 +318,7 @@ void Panel::initControls() {
auto state = _call->state();
if (state == State::Busy) {
_call->redial();
} else if ((_call->type() == Call::Type::Incoming) && ((state == State::Starting) || (state == State::WaitingIncoming))) {
} else if (_call->isIncomingWaiting()) {
_call->answer();
} else {
_call->hangup();
@ -702,11 +702,11 @@ void Panel::stateChanged(State state) {
button->toggleAnimated(visible);
}
};
auto waitingIncoming = (_call->type() == Call::Type::Incoming) && ((state == State::Starting) || (state == State::WaitingIncoming));
if (waitingIncoming) {
auto incomingWaiting = _call->isIncomingWaiting();
if (incomingWaiting) {
_updateOuterRippleTimer.callEach(Call::kSoundSampleMs);
}
toggleButton(_decline, waitingIncoming);
toggleButton(_decline, incomingWaiting);
toggleButton(_cancel, (state == State::Busy));
auto hangupShown = _decline->isHiddenOrHiding() && _cancel->isHiddenOrHiding();
if (_hangupShown != hangupShown) {