From 82a0ac28ad56b42616d41cd36c809d7b19d92643 Mon Sep 17 00:00:00 2001 From: John Preston Date: Tue, 26 Jul 2016 12:17:44 +0300 Subject: [PATCH] Handling new 2fa reset account error codes. Archived stickers description text layout fixed in 100% scale. --- Telegram/Resources/langs/lang.strings | 5 +++++ Telegram/SourceFiles/boxes/stickersetbox.cpp | 6 ++--- Telegram/SourceFiles/intro/intropwdcheck.cpp | 23 +++++++++++++++++++- 3 files changed, 30 insertions(+), 4 deletions(-) diff --git a/Telegram/Resources/langs/lang.strings b/Telegram/Resources/langs/lang.strings index 43c72f429c..5cda59404c 100644 --- a/Telegram/Resources/langs/lang.strings +++ b/Telegram/Resources/langs/lang.strings @@ -190,6 +190,11 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org "lng_signin_reset_account" = "Reset your account"; "lng_signin_sure_reset" = "Warning!\n\nYou will lose all your chats and messages, along with any media and files you shared!\n\nDo you want to reset your account?"; "lng_signin_reset" = "Reset"; +"lng_signin_reset_wait" = "Since the account {phone_number} is active and protected by a password, we will delete it in 1 week for security purposes. You can cancel this process at any time.\n\nYou’ll be able to reset your account in:\n{when}"; +"lng_signin_reset_in_days" = "{count_days:0 days|# day|# days} {count_hours:_not_used_|# hour|# hours} {count_minutes:_not_used_|# minute|# minutes}"; +"lng_signin_reset_in_hours" = "{count_hours:0 hours|# hour|# hours} {count_minutes:_not_used_|# minute|# minutes}"; +"lng_signin_reset_in_minutes" = "{count_minutes:0 minutes|# minute|# minutes}"; +"lng_signin_reset_cancelled" = "Your recent attempts to reset this account have been cancelled by its active user. Please try again in 7 days."; "lng_signup_title" = "Information and photo"; "lng_signup_desc" = "Please enter your name and\nupload a photo."; diff --git a/Telegram/SourceFiles/boxes/stickersetbox.cpp b/Telegram/SourceFiles/boxes/stickersetbox.cpp index 62c8c5580e..1a002920df 100644 --- a/Telegram/SourceFiles/boxes/stickersetbox.cpp +++ b/Telegram/SourceFiles/boxes/stickersetbox.cpp @@ -1280,7 +1280,7 @@ StickersInner::~StickersInner() { StickersBox::StickersBox(Section section) : ItemListBox(st::boxScroll) , _section(section) , _inner(section) -, _aboutWidth(st::boxWideWidth - st::contactsPadding.left() - st::contactsPadding.left()) +, _aboutWidth(st::boxWideWidth - 2 * st::stickersReorderPadding.top()) , _about(st::boxTextFont, lang((section == Section::Archived) ? lng_stickers_packs_archived : lng_stickers_reorder), _defaultOptions, _aboutWidth) { setup(); } @@ -1288,7 +1288,7 @@ StickersBox::StickersBox(Section section) : ItemListBox(st::boxScroll) StickersBox::StickersBox(const Stickers::Order &archivedIds) : ItemListBox(st::boxScroll) , _section(Section::ArchivedPart) , _inner(archivedIds) -, _aboutWidth(st::boxWideWidth - st::contactsPadding.left() - st::contactsPadding.left()) +, _aboutWidth(st::boxWideWidth - 2 * st::stickersReorderPadding.top()) , _about(st::boxTextFont, lang(lng_stickers_packs_archived), _defaultOptions, _aboutWidth) { setup(); } @@ -1507,7 +1507,7 @@ void StickersBox::paintEvent(QPaintEvent *e) { if (_aboutHeight > 0) { p.fillRect(0, 0, width(), _aboutHeight, st::contactsAboutBg); p.setPen(st::stickersReorderFg); - _about.draw(p, st::contactsPadding.left(), st::stickersReorderPadding.top(), _aboutWidth, style::al_center); + _about.draw(p, st::stickersReorderPadding.top(), st::stickersReorderPadding.top(), _aboutWidth, style::al_center); } } diff --git a/Telegram/SourceFiles/intro/intropwdcheck.cpp b/Telegram/SourceFiles/intro/intropwdcheck.cpp index ae6d34348e..c7da076c96 100644 --- a/Telegram/SourceFiles/intro/intropwdcheck.cpp +++ b/Telegram/SourceFiles/intro/intropwdcheck.cpp @@ -340,7 +340,28 @@ bool IntroPwdCheck::deleteFail(const RPCError &error) { if (MTP::isDefaultHandledError(error)) return false; sentRequest = 0; - showError(lang(lng_server_error)); + + auto type = error.type(); + if (type.startsWith(qstr("2FA_CONFIRM_WAIT_"))) { + int seconds = type.mid(qstr("2FA_CONFIRM_WAIT_").size()).toInt(); + int days = (seconds + 59) / 86400; + int hours = ((seconds + 59) % 86400) / 3600; + int minutes = ((seconds + 59) % 3600) / 60; + QString when; + if (days > 0) { + when = lng_signin_reset_in_days(lt_count_days, days, lt_count_hours, hours, lt_count_minutes, minutes); + } else if (hours > 0) { + when = lng_signin_reset_in_hours(lt_count_hours, hours, lt_count_minutes, minutes); + } else { + when = lng_signin_reset_in_minutes(lt_count_minutes, minutes); + } + Ui::showLayer(new InformBox(lng_signin_reset_wait(lt_phone_number, App::formatPhone(intro()->getPhone()), lt_when, when))); + } else if (type == qstr("2FA_RECENT_CONFIRM")) { + Ui::showLayer(new InformBox(lang(lng_signin_reset_cancelled))); + } else { + Ui::hideLayer(); + showError(lang(lng_server_error)); + } return true; }