From d71b6effd6936a0c268dba055d662d8617fb5c93 Mon Sep 17 00:00:00 2001 From: John Preston Date: Tue, 13 Apr 2021 17:51:42 +0400 Subject: [PATCH] Return request for code resend on auth. --- Telegram/SourceFiles/intro/intro_code.cpp | 26 ++++++++++++----------- 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/Telegram/SourceFiles/intro/intro_code.cpp b/Telegram/SourceFiles/intro/intro_code.cpp index ab5a825311..b99f86d979 100644 --- a/Telegram/SourceFiles/intro/intro_code.cpp +++ b/Telegram/SourceFiles/intro/intro_code.cpp @@ -397,18 +397,17 @@ void CodeWidget::submit() { } void CodeWidget::noTelegramCode() { - Ui::show(Box(tr::lng_code_register_phone(tr::now))); - //if (_noTelegramCodeRequestId) { - // return; - //} - //_noTelegramCodeRequestId = api().request(MTPauth_ResendCode( - // MTP_string(getData()->phone), - // MTP_bytes(getData()->phoneHash) - //)).done([=](const MTPauth_SentCode &result) { - // noTelegramCodeDone(result); - //}).fail([=](const MTP::Error &error) { - // noTelegramCodeFail(error); - //}).handleFloodErrors().send(); + if (_noTelegramCodeRequestId) { + return; + } + _noTelegramCodeRequestId = api().request(MTPauth_ResendCode( + MTP_string(getData()->phone), + MTP_bytes(getData()->phoneHash) + )).done([=](const MTPauth_SentCode &result) { + noTelegramCodeDone(result); + }).fail([=](const MTP::Error &error) { + noTelegramCodeFail(error); + }).handleFloodErrors().send(); } void CodeWidget::noTelegramCodeDone(const MTPauth_SentCode &result) { @@ -439,6 +438,9 @@ void CodeWidget::noTelegramCodeFail(const MTP::Error &error) { _noTelegramCodeRequestId = 0; showCodeError(tr::lng_flood_error()); return; + } else if (error.type() == u"SEND_CODE_UNAVAILABLE"_q) { + _noTelegramCodeRequestId = 0; + return; } _noTelegramCodeRequestId = 0;