From 2ca763cc77f213aa2e07c437dda9232b3c903d22 Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Mon, 27 Jan 2025 20:28:30 +0300 Subject: [PATCH] Made less strict condition to show unique status of gift in gift box. --- .../SourceFiles/boxes/gift_premium_box.cpp | 35 +++++++++++-------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/Telegram/SourceFiles/boxes/gift_premium_box.cpp b/Telegram/SourceFiles/boxes/gift_premium_box.cpp index bc226f66f..987538be5 100644 --- a/Telegram/SourceFiles/boxes/gift_premium_box.cpp +++ b/Telegram/SourceFiles/boxes/gift_premium_box.cpp @@ -474,27 +474,34 @@ void AddTableRow( table->st().defaultValue, st::defaultPopupMenu); - const auto upgrade = Ui::CreateChild( - raw, - tr::lng_gift_unique_status_upgrade(), - table->st().smallButton); - upgrade->setTextTransform(Ui::RoundButton::TextTransform::NoTransform); - upgrade->setClickedCallback(startUpgrade); + const auto upgrade = startUpgrade + ? Ui::CreateChild( + raw, + tr::lng_gift_unique_status_upgrade(), + table->st().smallButton) + : (Ui::RoundButton*)(nullptr); + if (upgrade) { + using namespace Ui; + upgrade->setTextTransform(RoundButton::TextTransform::NoTransform); + upgrade->setClickedCallback(startUpgrade); + } rpl::combine( raw->widthValue(), - upgrade->widthValue() + upgrade ? upgrade->widthValue() : rpl::single(0) ) | rpl::start_with_next([=](int width, int toggleWidth) { const auto toggleSkip = toggleWidth ? (st::normalFont->spacew + toggleWidth) : 0; label->resizeToNaturalWidth(width - toggleSkip); label->moveToLeft(0, 0, width); - upgrade->moveToLeft( - label->width() + st::normalFont->spacew, - (table->st().defaultValue.style.font->ascent - - table->st().smallButton.style.font->ascent), - width); + if (upgrade) { + upgrade->moveToLeft( + label->width() + st::normalFont->spacew, + (table->st().defaultValue.style.font->ascent + - table->st().smallButton.style.font->ascent), + width); + } }, label->lifetime()); label->heightValue() | rpl::start_with_next([=](int height) { @@ -1390,7 +1397,7 @@ void AddStarGiftTable( ? MakePeerTableValue(table, show, PeerId(entry.bareActorId)) : MakeHiddenPeerTableValue(table)), st::giveawayGiftCodePeerMargin); - if (!entry.fromGiftsList) { + if (entry.bareGiftListPeerId) { AddTableRow( table, tr::lng_credits_box_history_entry_peer(), @@ -1500,7 +1507,7 @@ void AddStarGiftTable( std::move(amount), Ui::Text::WithEntities))); } - if (!unique && startUpgrade) { + if (!unique && !entry.soldOutInfo) { AddTableRow( table, tr::lng_gift_unique_status(),