From c220d4dd17c9e68f870dc54695ab410c9e65d07d Mon Sep 17 00:00:00 2001 From: John Preston Date: Wed, 23 Apr 2025 16:38:40 +0400 Subject: [PATCH] Handle STARGIFT_RESELL_TOO_EARLY error. --- Telegram/Resources/langs/lang.strings | 1 + Telegram/SourceFiles/boxes/star_gift_box.cpp | 17 ++++++++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/Telegram/Resources/langs/lang.strings b/Telegram/Resources/langs/lang.strings index d1a9ad9c3e..229a8f23cf 100644 --- a/Telegram/Resources/langs/lang.strings +++ b/Telegram/Resources/langs/lang.strings @@ -3631,6 +3631,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL "lng_gift_resale_symbol" = "Symbol"; "lng_gift_resale_symbols#one" = "{count} Symbol"; "lng_gift_resale_symbols#other" = "{count} Symbols"; +"lng_gift_resale_early" = "You will be able to resell this gift in {duration}."; "lng_accounts_limit_title" = "Limit Reached"; "lng_accounts_limit1#one" = "You have reached the limit of **{count}** connected account."; diff --git a/Telegram/SourceFiles/boxes/star_gift_box.cpp b/Telegram/SourceFiles/boxes/star_gift_box.cpp index 6a7eeae47a..fe89376a5f 100644 --- a/Telegram/SourceFiles/boxes/star_gift_box.cpp +++ b/Telegram/SourceFiles/boxes/star_gift_box.cpp @@ -4194,7 +4194,22 @@ void UpdateGiftSellPrice( .action = Data::GiftUpdate::Action::ResaleChange, }); }).fail([=](const MTP::Error &error) { - show->showToast(error.type()); + const auto earlyPrefix = u"STARGIFT_RESELL_TOO_EARLY_"_q; + const auto type = error.type(); + if (type.startsWith(earlyPrefix)) { + const auto seconds = type.mid(earlyPrefix.size()).toInt(); + const auto days = seconds / 86400; + const auto hours = seconds / 3600; + const auto minutes = std::max(seconds / 60, 1); + show->showToast( + tr::lng_gift_resale_early(tr::now, lt_duration, days + ? tr::lng_days(tr::now, lt_count, days) + : hours + ? tr::lng_hours(tr::now, lt_count, hours) + : tr::lng_minutes(tr::now, lt_count, minutes))); + } else { + show->showToast(type); + } }).send(); }