mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-09-01 06:55:58 +00:00
Don't change dc after qr request / phone submit.
This commit is contained in:
@@ -132,7 +132,9 @@ void PhoneWidget::phoneChanged() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void PhoneWidget::submit() {
|
void PhoneWidget::submit() {
|
||||||
if (_sentRequest || isHidden()) return;
|
if (_sentRequest || isHidden()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const auto phone = fullNumber();
|
const auto phone = fullNumber();
|
||||||
if (!AllowPhoneAttempt(phone)) {
|
if (!AllowPhoneAttempt(phone)) {
|
||||||
@@ -141,6 +143,8 @@ void PhoneWidget::submit() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cancelNearestDcRequest();
|
||||||
|
|
||||||
// Check if such account is authorized already.
|
// Check if such account is authorized already.
|
||||||
const auto digitsOnly = [](QString value) {
|
const auto digitsOnly = [](QString value) {
|
||||||
return value.replace(QRegularExpression("[^0-9]"), QString());
|
return value.replace(QRegularExpression("[^0-9]"), QString());
|
||||||
|
@@ -179,6 +179,8 @@ QrWidget::QrWidget(
|
|||||||
setDescriptionText(rpl::single(QString()));
|
setDescriptionText(rpl::single(QString()));
|
||||||
setErrorCentered(true);
|
setErrorCentered(true);
|
||||||
|
|
||||||
|
cancelNearestDcRequest();
|
||||||
|
|
||||||
account->mtpUpdates(
|
account->mtpUpdates(
|
||||||
) | rpl::start_with_next([=](const MTPUpdates &updates) {
|
) | rpl::start_with_next([=](const MTPUpdates &updates) {
|
||||||
checkForTokenUpdate(updates);
|
checkForTokenUpdate(updates);
|
||||||
|
@@ -502,6 +502,10 @@ void Step::setShowTermsCallback(Fn<void()> callback) {
|
|||||||
_showTermsCallback = std::move(callback);
|
_showTermsCallback = std::move(callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Step::setCancelNearestDcCallback(Fn<void()> callback) {
|
||||||
|
_cancelNearestDcCallback = std::move(callback);
|
||||||
|
}
|
||||||
|
|
||||||
void Step::setAcceptTermsCallback(
|
void Step::setAcceptTermsCallback(
|
||||||
Fn<void(Fn<void()> callback)> callback) {
|
Fn<void(Fn<void()> callback)> callback) {
|
||||||
_acceptTermsCallback = std::move(callback);
|
_acceptTermsCallback = std::move(callback);
|
||||||
|
@@ -58,8 +58,8 @@ public:
|
|||||||
void setGoCallback(
|
void setGoCallback(
|
||||||
Fn<void(Step *step, StackAction action, Animate animate)> callback);
|
Fn<void(Step *step, StackAction action, Animate animate)> callback);
|
||||||
void setShowResetCallback(Fn<void()> callback);
|
void setShowResetCallback(Fn<void()> callback);
|
||||||
void setShowTermsCallback(
|
void setShowTermsCallback(Fn<void()> callback);
|
||||||
Fn<void()> callback);
|
void setCancelNearestDcCallback(Fn<void()> callback);
|
||||||
void setAcceptTermsCallback(
|
void setAcceptTermsCallback(
|
||||||
Fn<void(Fn<void()> callback)> callback);
|
Fn<void(Fn<void()> callback)> callback);
|
||||||
|
|
||||||
@@ -130,6 +130,9 @@ protected:
|
|||||||
_acceptTermsCallback(callback);
|
_acceptTermsCallback(callback);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
void cancelNearestDcRequest() {
|
||||||
|
if (_cancelNearestDcCallback) _cancelNearestDcCallback();
|
||||||
|
}
|
||||||
|
|
||||||
virtual int errorTop() const;
|
virtual int errorTop() const;
|
||||||
|
|
||||||
@@ -176,6 +179,7 @@ private:
|
|||||||
Fn<void(Step *step, StackAction action, Animate animate)> _goCallback;
|
Fn<void(Step *step, StackAction action, Animate animate)> _goCallback;
|
||||||
Fn<void()> _showResetCallback;
|
Fn<void()> _showResetCallback;
|
||||||
Fn<void()> _showTermsCallback;
|
Fn<void()> _showTermsCallback;
|
||||||
|
Fn<void()> _cancelNearestDcCallback;
|
||||||
Fn<void(Fn<void()> callback)> _acceptTermsCallback;
|
Fn<void(Fn<void()> callback)> _acceptTermsCallback;
|
||||||
|
|
||||||
rpl::variable<QString> _titleText;
|
rpl::variable<QString> _titleText;
|
||||||
|
@@ -65,6 +65,8 @@ Widget::Widget(
|
|||||||
rpl::single(true))) {
|
rpl::single(true))) {
|
||||||
Core::App().setDefaultFloatPlayerDelegate(floatPlayerDelegate());
|
Core::App().setDefaultFloatPlayerDelegate(floatPlayerDelegate());
|
||||||
|
|
||||||
|
getNearestDC();
|
||||||
|
|
||||||
switch (point) {
|
switch (point) {
|
||||||
case EnterPoint::Start:
|
case EnterPoint::Start:
|
||||||
appendStep(new StartWidget(this, _account, getData()));
|
appendStep(new StartWidget(this, _account, getData()));
|
||||||
@@ -104,8 +106,6 @@ Widget::Widget(
|
|||||||
|
|
||||||
_settings->entity()->setClickedCallback([] { App::wnd()->showSettings(); });
|
_settings->entity()->setClickedCallback([] { App::wnd()->showSettings(); });
|
||||||
|
|
||||||
getNearestDC();
|
|
||||||
|
|
||||||
if (_changeLanguage) {
|
if (_changeLanguage) {
|
||||||
_changeLanguage->finishAnimating();
|
_changeLanguage->finishAnimating();
|
||||||
}
|
}
|
||||||
@@ -378,9 +378,14 @@ void Widget::appendStep(Step *step) {
|
|||||||
step->setShowResetCallback([=] {
|
step->setShowResetCallback([=] {
|
||||||
showResetButton();
|
showResetButton();
|
||||||
});
|
});
|
||||||
step->setShowTermsCallback([=]() {
|
step->setShowTermsCallback([=] {
|
||||||
showTerms();
|
showTerms();
|
||||||
});
|
});
|
||||||
|
step->setCancelNearestDcCallback([=] {
|
||||||
|
if (_api) {
|
||||||
|
_api->request(base::take(_nearestDcRequestId)).cancel();
|
||||||
|
}
|
||||||
|
});
|
||||||
step->setAcceptTermsCallback([=](Fn<void()> callback) {
|
step->setAcceptTermsCallback([=](Fn<void()> callback) {
|
||||||
acceptTerms(callback);
|
acceptTerms(callback);
|
||||||
});
|
});
|
||||||
@@ -519,8 +524,9 @@ void Widget::getNearestDC() {
|
|||||||
if (!_api) {
|
if (!_api) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_api->request(MTPhelp_GetNearestDc(
|
_nearestDcRequestId = _api->request(MTPhelp_GetNearestDc(
|
||||||
)).done([=](const MTPNearestDc &result) {
|
)).done([=](const MTPNearestDc &result) {
|
||||||
|
_nearestDcRequestId = 0;
|
||||||
const auto &nearest = result.c_nearestDc();
|
const auto &nearest = result.c_nearestDc();
|
||||||
DEBUG_LOG(("Got nearest dc, country: %1, nearest: %2, this: %3"
|
DEBUG_LOG(("Got nearest dc, country: %1, nearest: %2, this: %3"
|
||||||
).arg(qs(nearest.vcountry())
|
).arg(qs(nearest.vcountry())
|
||||||
|
@@ -167,6 +167,7 @@ private:
|
|||||||
|
|
||||||
const not_null<Main::Account*> _account;
|
const not_null<Main::Account*> _account;
|
||||||
std::optional<MTP::Sender> _api;
|
std::optional<MTP::Sender> _api;
|
||||||
|
mtpRequestId _nearestDcRequestId = 0;
|
||||||
|
|
||||||
Ui::Animations::Simple _a_show;
|
Ui::Animations::Simple _a_show;
|
||||||
bool _showBack = false;
|
bool _showBack = false;
|
||||||
|
@@ -417,8 +417,9 @@ void Instance::Private::setGoodProxyDomain(
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Instance::Private::suggestMainDcId(DcId mainDcId) {
|
void Instance::Private::suggestMainDcId(DcId mainDcId) {
|
||||||
if (_mainDcIdForced) return;
|
if (!_mainDcIdForced) {
|
||||||
setMainDcId(mainDcId);
|
setMainDcId(mainDcId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Instance::Private::setMainDcId(DcId mainDcId) {
|
void Instance::Private::setMainDcId(DcId mainDcId) {
|
||||||
|
Reference in New Issue
Block a user