Handle the outdated app error in passport.

This commit is contained in:
John Preston 2018-07-10 23:15:54 +03:00
parent 7be9e0fb94
commit 39b0d9e46f
8 changed files with 34 additions and 4 deletions

View File

@ -1665,6 +1665,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
"lng_passport_error_cant_read" = "Can't read this file. Please choose an image.";
"lng_passport_bad_name" = "Please use latin characters only.";
"lng_passport_wait_upload" = "Please wait while upload is finished.";
"lng_passport_app_out_of_date" = "Sorry, your Telegram app is out of date and can't handle this request. Please update Telegram.";
"lng_export_title" = "Export Personal Data";
"lng_export_progress_title" = "Exporting personal data";

View File

@ -2108,6 +2108,7 @@ void UpdateApplication() {
if (weak) {
weak->scrollToUpdateRow();
}
window->showFromTray();
}
}

View File

@ -2060,8 +2060,12 @@ void FormController::parseForm(const MTPaccount_AuthorizationForm &result) {
void FormController::formFail(const QString &error) {
_savedPasswordValue = QByteArray();
_serviceErrorText = error;
_view->showCriticalError(
lang(lng_passport_form_error) + "\n" + error);
if (error == "APP_VERSION_OUTDATED") {
_view->showUpdateAppBox();
} else {
_view->showCriticalError(
lang(lng_passport_form_error) + "\n" + error);
}
}
void FormController::requestPassword() {

View File

@ -43,6 +43,7 @@ public:
virtual void showAskPassword() = 0;
virtual void showNoPassword() = 0;
virtual void showCriticalError(const QString &error) = 0;
virtual void showUpdateAppBox() = 0;
virtual void editScope(int index) = 0;
virtual void showBox(

View File

@ -98,6 +98,7 @@ void Panel::showBox(
LayerOptions options,
anim::type animated) {
_widget->showBox(std::move(box), options, animated);
_widget->showAndActivate();
}
void Panel::showToast(const QString &text) {

View File

@ -19,6 +19,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/toast/toast.h"
#include "ui/rp_widget.h"
#include "ui/countryinput.h"
#include "core/update_checker.h"
#include "layout.h"
#include "styles/style_boxes.h"
@ -812,6 +813,24 @@ void PanelController::showCriticalError(const QString &error) {
_panel->showCriticalError(error);
}
void PanelController::showUpdateAppBox() {
ensurePanelCreated();
const auto box = std::make_shared<QPointer<BoxContent>>();
const auto callback = [=] {
_form->cancelSure();
Core::UpdateApplication();
};
*box = show(
Box<ConfirmBox>(
lang(lng_passport_app_out_of_date),
lang(lng_menu_update),
callback,
[=] { _form->cancelSure(); }),
LayerOption::KeepOther,
anim::type::instant);
}
void PanelController::ensurePanelCreated() {
if (!_panel) {
_panel = std::make_unique<Panel>(this);

View File

@ -97,6 +97,7 @@ public:
void showAskPassword() override;
void showNoPassword() override;
void showCriticalError(const QString &error) override;
void showUpdateAppBox() override;
void fillRows(
Fn<void(

View File

@ -223,7 +223,9 @@ void SeparatePanel::finishAnimating() {
_animationCache = QPixmap();
if (_visible) {
showControls();
_inner->setFocus();
if (_inner) {
_inner->setFocus();
}
} else {
finishClose();
}
@ -317,7 +319,7 @@ void SeparatePanel::focusInEvent(QFocusEvent *e) {
crl::on_main(this, [=] {
if (_layer) {
_layer->setInnerFocus();
} else if (!_inner->isHidden()) {
} else if (_inner && !_inner->isHidden()) {
_inner->setFocus();
}
});