From e0eec138d5effb2a5a8b296b22b5b480424e3cf4 Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Mon, 21 Feb 2022 04:31:11 +0300 Subject: [PATCH] Removed Ui::hideLayer from ChangePhoneBox::EnterCode. --- .../SourceFiles/boxes/change_phone_box.cpp | 26 +++++++++++-------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/Telegram/SourceFiles/boxes/change_phone_box.cpp b/Telegram/SourceFiles/boxes/change_phone_box.cpp index 3033a2e939..0fc45233e5 100644 --- a/Telegram/SourceFiles/boxes/change_phone_box.cpp +++ b/Telegram/SourceFiles/boxes/change_phone_box.cpp @@ -101,7 +101,7 @@ class ChangePhoneBox::EnterCode : public Ui::BoxContent { public: EnterCode( QWidget*, - not_null session, + not_null controller, const QString &phone, const QString &hash, int codeLength, @@ -125,7 +125,7 @@ private: } int countHeight(); - const not_null _session; + const not_null _controller; MTP::Sender _api; QString _phone; @@ -247,7 +247,7 @@ void ChangePhoneBox::EnterPhone::sendPhoneDone( }(); _controller->show( Box( - &_controller->session(), + _controller, phoneNumber, phoneCodeHash, codeLength, @@ -291,13 +291,13 @@ void ChangePhoneBox::EnterPhone::showError(const QString &text) { ChangePhoneBox::EnterCode::EnterCode( QWidget*, - not_null session, + not_null controller, const QString &phone, const QString &hash, int codeLength, int callTimeout) -: _session(session) -, _api(&session->mtp()) +: _controller(controller) +, _api(&controller->session().mtp()) , _phone(phone) , _hash(hash) , _codeLength(codeLength) @@ -355,20 +355,24 @@ void ChangePhoneBox::EnterCode::submit() { } hideError(); - const auto session = _session; + const auto session = &_controller->session(); const auto code = _code->getDigitsOnly(); const auto weak = Ui::MakeWeak(this); _requestId = session->api().request(MTPaccount_ChangePhone( MTP_string(_phone), MTP_string(_hash), MTP_string(code) - )).done([=](const MTPUser &result) { + )).done([=, show = Window::Show(_controller)](const MTPUser &result) { _requestId = 0; session->data().processUser(result); - if (weak) { - Ui::hideLayer(); + if (show.valid()) { + if (weak) { + show.hideLayer(); + } + Ui::Toast::Show( + show.toastParent(), + tr::lng_change_phone_success(tr::now)); } - Ui::Toast::Show(tr::lng_change_phone_success(tr::now)); }).fail(crl::guard(this, [=](const MTP::Error &error) { _requestId = 0; sendCodeFail(error);