From fc2fd60cdbe18fdb6f8961f072bbf0cfed22aef0 Mon Sep 17 00:00:00 2001 From: John Preston Date: Wed, 18 Feb 2026 15:04:48 +0400 Subject: [PATCH] Check first craft gift address. --- Telegram/Resources/langs/lang.strings | 1 + .../SourceFiles/boxes/star_gift_craft_box.cpp | 37 +++++++++++++++---- .../SourceFiles/boxes/star_gift_craft_box.h | 4 ++ .../settings/settings_credits_graphics.cpp | 6 +++ 4 files changed, 41 insertions(+), 7 deletions(-) diff --git a/Telegram/Resources/langs/lang.strings b/Telegram/Resources/langs/lang.strings index f7cff57c6f..1d47d2aebd 100644 --- a/Telegram/Resources/langs/lang.strings +++ b/Telegram/Resources/langs/lang.strings @@ -4201,6 +4201,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL "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}."; +"lng_gift_craft_address_error" = "This gift has been exported to the blockchain and can't be used as the primary gift for crafting."; "lng_auction_about_title" = "Auction"; "lng_auction_about_subtitle" = "Join the battle for exclusive gifts."; diff --git a/Telegram/SourceFiles/boxes/star_gift_craft_box.cpp b/Telegram/SourceFiles/boxes/star_gift_craft_box.cpp index 70c7e61540..995761bd3a 100644 --- a/Telegram/SourceFiles/boxes/star_gift_craft_box.cpp +++ b/Telegram/SourceFiles/boxes/star_gift_craft_box.cpp @@ -660,7 +660,8 @@ void ShowSelectGiftBox( uint64 giftId, Fn chosen, std::vector selected, - Fn boxClosed) { + Fn boxClosed, + bool firstSlot) { struct Entry { Data::SavedStarGift gift; GiftButton *button = nullptr; @@ -690,10 +691,13 @@ void ShowSelectGiftBox( const auto got = crl::guard(box, [=]( std::shared_ptr gift) { - if (!ShowCraftLaterError(box->uiShow(), gift)) { - chosen(GiftForCraft{ .unique = gift }); - box->closeBox(); + if (ShowCraftLaterError(box->uiShow(), gift) + || (firstSlot + && ShowCraftAddressError(box->uiShow(), gift))) { + return; } + chosen(GiftForCraft{ .unique = gift }); + box->closeBox(); }); AddCraftGiftsList( @@ -1190,7 +1194,7 @@ void Craft( ShowSelectGiftBox(controller, giftId, [=](GiftForCraft chosen) { ShowGiftCraftBox(controller, { chosen }, false); closeCurrent(); - }, {}, [=] { *requested = false; }); + }, {}, [=] { *requested = false; }, true); }; StartCraftAnimation( box, @@ -1415,12 +1419,14 @@ void MakeCraftContent( } state->chosen = std::move(copy); }; + const auto first = (state->requestingIndex == 0); ShowSelectGiftBox( controller, giftId, crl::guard(raw, callback), state->chosen.current(), - crl::guard(raw, [=] { state->requestingIndex = -1; })); + crl::guard(raw, [=] { state->requestingIndex = -1; }), + first); }, raw->lifetime()); auto fullName = state->chosen.value( @@ -1497,10 +1503,14 @@ void MakeCraftContent( if (state->crafting) { return; } + const auto &gifts = state->chosen.current(); + if (!gifts.empty() + && ShowCraftAddressError(box->uiShow(), gifts.front().unique)) { + return; + } state->crafting = true; const auto &cs = state->craftState; - const auto &gifts = state->chosen.current(); cs->giftName = state->name.current(); cs->successPermille = state->successPercentPermille.current(); @@ -1731,4 +1741,17 @@ void ShowCraftLaterError( })); } +bool ShowCraftAddressError( + std::shared_ptr show, + std::shared_ptr gift) { + if (gift->giftAddress.isEmpty()) { + return false; + } + show->show(MakeInformBox({ + .text = tr::lng_gift_craft_address_error(tr::marked), + .title = tr::lng_gift_craft_unavailable(), + })); + return true; +} + } // namespace Ui diff --git a/Telegram/SourceFiles/boxes/star_gift_craft_box.h b/Telegram/SourceFiles/boxes/star_gift_craft_box.h index 283235668e..26eb5f2be7 100644 --- a/Telegram/SourceFiles/boxes/star_gift_craft_box.h +++ b/Telegram/SourceFiles/boxes/star_gift_craft_box.h @@ -43,4 +43,8 @@ void ShowCraftLaterError( std::shared_ptr show, TimeId when); +[[nodiscard]] bool ShowCraftAddressError( + std::shared_ptr show, + std::shared_ptr gift); + } // namespace Ui diff --git a/Telegram/SourceFiles/settings/settings_credits_graphics.cpp b/Telegram/SourceFiles/settings/settings_credits_graphics.cpp index a308fd9634..3d0d17b451 100644 --- a/Telegram/SourceFiles/settings/settings_credits_graphics.cpp +++ b/Telegram/SourceFiles/settings/settings_credits_graphics.cpp @@ -1135,6 +1135,9 @@ void FillUniqueGiftMenu( if (Ui::ShowCraftLaterError(show, unique)) { return; } + if (Ui::ShowCraftAddressError(show, unique)) { + return; + } const auto savedId = EntryToSavedStarGiftId(&show->session(), e); if (const auto window = show->resolveWindow()) { Ui::ShowGiftCraftInfoBox(window, unique, savedId); @@ -1604,6 +1607,9 @@ void GenericCreditsEntryBody( if (Ui::ShowCraftLaterError(show, unique)) { return; } + if (Ui::ShowCraftAddressError(show, unique)) { + return; + } const auto savedId = EntryToSavedStarGiftId(&show->session(), e); if (const auto window = show->resolveWindow()) { Ui::ShowGiftCraftInfoBox(window, unique, savedId);