Handle STARGIFT_RESELL_TOO_EARLY error.

This commit is contained in:
John Preston 2025-04-23 16:38:40 +04:00
parent 15146725e3
commit c220d4dd17
2 changed files with 17 additions and 1 deletions

View file

@ -3631,6 +3631,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
"lng_gift_resale_symbol" = "Symbol"; "lng_gift_resale_symbol" = "Symbol";
"lng_gift_resale_symbols#one" = "{count} Symbol"; "lng_gift_resale_symbols#one" = "{count} Symbol";
"lng_gift_resale_symbols#other" = "{count} Symbols"; "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_limit_title" = "Limit Reached";
"lng_accounts_limit1#one" = "You have reached the limit of **{count}** connected account."; "lng_accounts_limit1#one" = "You have reached the limit of **{count}** connected account.";

View file

@ -4194,7 +4194,22 @@ void UpdateGiftSellPrice(
.action = Data::GiftUpdate::Action::ResaleChange, .action = Data::GiftUpdate::Action::ResaleChange,
}); });
}).fail([=](const MTP::Error &error) { }).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(); }).send();
} }