From 8efbd7a1cb2d6012e51a4bfa4de133d45d93752e Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Sun, 17 Dec 2023 12:58:47 +0300 Subject: [PATCH] Added ability to hide subscription button in preview premium boxes. --- Telegram/SourceFiles/boxes/premium_preview_box.cpp | 10 +++++++--- Telegram/SourceFiles/boxes/premium_preview_box.h | 3 ++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/Telegram/SourceFiles/boxes/premium_preview_box.cpp b/Telegram/SourceFiles/boxes/premium_preview_box.cpp index 6cdb9a10a..92240b424 100644 --- a/Telegram/SourceFiles/boxes/premium_preview_box.cpp +++ b/Telegram/SourceFiles/boxes/premium_preview_box.cpp @@ -66,6 +66,7 @@ struct Descriptor { bool fromSettings = false; Fn hiddenCallback; Fn)> shownCallback; + bool hideSubscriptionButton = false; }; bool operator==(const Descriptor &a, const Descriptor &b) { @@ -1025,7 +1026,8 @@ void PreviewBox( state->preload(); } }; - if (descriptor.fromSettings && show->session().premium()) { + if ((descriptor.fromSettings && show->session().premium()) + || descriptor.hideSubscriptionButton) { box->setShowFinishedCallback(showFinished); box->addButton(tr::lng_close(), [=] { box->closeBox(); }); } else { @@ -1151,7 +1153,7 @@ void DecorateListPromoBox( box->boxClosing() | rpl::start_with_next(hidden, box->lifetime()); } - if (session->premium()) { + if (session->premium() || descriptor.hideSubscriptionButton) { box->addButton(tr::lng_close(), [=] { box->closeBox(); }); @@ -1286,10 +1288,12 @@ void ShowPremiumPreviewBox( void ShowPremiumPreviewBox( std::shared_ptr show, PremiumPreview section, - Fn)> shown) { + Fn)> shown, + bool hideSubscriptionButton) { Show(std::move(show), Descriptor{ .section = section, .shownCallback = std::move(shown), + .hideSubscriptionButton = hideSubscriptionButton, }); } diff --git a/Telegram/SourceFiles/boxes/premium_preview_box.h b/Telegram/SourceFiles/boxes/premium_preview_box.h index 35c055717..60c5699ca 100644 --- a/Telegram/SourceFiles/boxes/premium_preview_box.h +++ b/Telegram/SourceFiles/boxes/premium_preview_box.h @@ -73,7 +73,8 @@ void ShowPremiumPreviewBox( void ShowPremiumPreviewBox( std::shared_ptr show, PremiumPreview section, - Fn)> shown = nullptr); + Fn)> shown = nullptr, + bool hideSubscriptionButton = false); void ShowPremiumPreviewToBuy( not_null controller,