Allow crafting another gift after success.

This commit is contained in:
John Preston
2026-02-06 20:30:40 +04:00
parent dad5f9511c
commit 955319fc23
6 changed files with 20 additions and 3 deletions
+1
View File
@@ -4158,6 +4158,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
"lng_gift_craft_failed_about#one" = "This crafting attempt was unsuccessful.\n**{count}** gift was lost.";
"lng_gift_craft_failed_about#other" = "This crafting attempt was unsuccessful.\n**{count}** gifts were lost.";
"lng_gift_craft_new_button" = "Craft New Gift";
"lng_gift_craft_another_button" = "Craft Another Gift";
"lng_gift_craft_unavailable" = "Crafting unavailable";
"lng_gift_craft_when" = "This gift will become available for crafting on {date} at {time}.";
+3 -1
View File
@@ -3355,7 +3355,8 @@ void AddUpgradeGiftCover(
Data::CreditsHistoryEntry EntryForUpgradedGift(
const std::shared_ptr<Data::GiftUpgradeResult> &gift,
uint64 nextToUpgradeStickerId,
Fn<void()> nextToUpgradeShow) {
Fn<void()> nextToUpgradeShow,
Fn<void()> craftAnother) {
Expects(gift != nullptr);
const auto unique = gift->info.unique;
@@ -3378,6 +3379,7 @@ Data::CreditsHistoryEntry EntryForUpgradedGift(
.uniqueGift = unique,
.nextToUpgradeStickerId = nextToUpgradeStickerId,
.nextToUpgradeShow = nextToUpgradeShow,
.craftAnotherCallback = craftAnother,
.peerType = Data::CreditsHistoryEntry::PeerType::Peer,
.limitedCount = gift->info.limitedCount,
.limitedLeft = gift->info.limitedLeft,
+2 -1
View File
@@ -183,7 +183,8 @@ void SendGiftBox(
[[nodiscard]] Data::CreditsHistoryEntry EntryForUpgradedGift(
const std::shared_ptr<Data::GiftUpgradeResult> &gift,
uint64 nextToUpgradeStickerId = 0,
Fn<void()> nextToUpgradeShow = nullptr);
Fn<void()> nextToUpgradeShow = nullptr,
Fn<void()> craftAnother = nullptr);
[[nodiscard]] std::shared_ptr<Data::GiftUpgradeResult> FindUniqueGift(
not_null<Main::Session*> session,
@@ -1897,8 +1897,15 @@ void StartCraftAnimation(
box->setStyle(st::giftBox);
auto craftAnotherCallback = crl::guard(box, [=] {
retryWithNewGift([=] { box->closeBox(); });
});
const auto entry = EntryForUpgradedGift(
*state->craftResult);
*state->craftResult,
0,
nullptr,
craftAnotherCallback);
Settings::GenericCreditsEntryBody(box, show, entry);
container->resizeToWidth(st::boxWideWidth);
+1
View File
@@ -83,6 +83,7 @@ struct CreditsHistoryEntry final {
Fn<std::vector<CreditsHistoryEntry>()> pinnedSavedGifts;
uint64 nextToUpgradeStickerId = 0;
Fn<void()> nextToUpgradeShow;
Fn<void()> craftAnotherCallback;
CreditsAmount starrefAmount;
int starrefCommission = 0;
uint64 starrefRecipientId = 0;
@@ -2286,6 +2286,8 @@ void GenericCreditsEntryBody(
? tr::lng_credits_subscription_off_button()
: toRejoin
? tr::lng_credits_subscription_off_rejoin_button()
: e.craftAnotherCallback
? tr::lng_gift_craft_another_button()
: canUpgradeFree
? tr::lng_gift_upgrade_free()
: canUpgrade
@@ -2350,6 +2352,9 @@ void GenericCreditsEntryBody(
showNextToUpgrade();
close();
return;
} else if (e.craftAnotherCallback) {
e.craftAnotherCallback();
return;
} else if (state->confirmButtonBusy.current()
|| state->convertButtonBusy.current()) {
return;