diff --git a/Telegram/Resources/langs/lang.strings b/Telegram/Resources/langs/lang.strings index 82e5dfb682..d177c032c2 100644 --- a/Telegram/Resources/langs/lang.strings +++ b/Telegram/Resources/langs/lang.strings @@ -2410,7 +2410,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL "lng_credits_box_history_entry_gift_out_about" = "With Stars, **{user}** will be able to unlock content and services on Telegram.\n{link}"; "lng_credits_box_history_entry_gift_in_about" = "Use Stars to unlock content and services on Telegram. {link}"; "lng_credits_box_history_entry_gift_about_link" = "See Examples {emoji}"; -"lng_credits_box_history_entry_gift_about_url" = "https://telegram.org/blog/telegram-stars"; +"lng_credits_box_history_entry_gift_examples" = "Examples"; "lng_credits_box_history_entry_ads" = "Ads Platform"; "lng_credits_box_history_entry_premium_bot" = "Stars Top-Up"; "lng_credits_box_history_entry_via_premium_bot" = "Premium Bot"; diff --git a/Telegram/SourceFiles/boxes/gift_credits_box.cpp b/Telegram/SourceFiles/boxes/gift_credits_box.cpp index 0b20d498ed..f0ecd05f63 100644 --- a/Telegram/SourceFiles/boxes/gift_credits_box.cpp +++ b/Telegram/SourceFiles/boxes/gift_credits_box.cpp @@ -98,7 +98,7 @@ void GiftCreditsBox( ) | rpl::map([](TextWithEntities text) { return Ui::Text::Link( std::move(text), - tr::lng_credits_box_history_entry_gift_about_url(tr::now)); + u"internal:stars_examples"_q); }); content->add( object_ptr>( diff --git a/Telegram/SourceFiles/core/local_url_handlers.cpp b/Telegram/SourceFiles/core/local_url_handlers.cpp index 2f27eb062f..566df8c94c 100644 --- a/Telegram/SourceFiles/core/local_url_handlers.cpp +++ b/Telegram/SourceFiles/core/local_url_handlers.cpp @@ -19,6 +19,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "core/update_checker.h" #include "core/application.h" #include "core/click_handler_types.h" +#include "dialogs/ui/dialogs_suggestions.h" #include "boxes/background_preview_box.h" #include "ui/boxes/confirm_box.h" #include "ui/boxes/edit_birthday_box.h" @@ -923,6 +924,17 @@ bool ShowCollectibleUsername( return true; } +bool ShowStarsExamples( + Window::SessionController *controller, + const Match &match, + const QVariant &context) { + if (!controller) { + return false; + } + controller->show(Dialogs::StarsExamplesBox(controller)); + return true; +} + void ExportTestChatTheme( not_null controller, not_null theme) { @@ -1380,6 +1392,10 @@ const std::vector &InternalUrlHandlers() { u"^collectible_username/([a-zA-Z0-9\\-\\_\\.]+)@([0-9]+)$"_q, ShowCollectibleUsername, }, + { + u"^stars_examples$"_q, + ShowStarsExamples, + }, }; return Result; } diff --git a/Telegram/SourceFiles/dialogs/ui/dialogs_suggestions.cpp b/Telegram/SourceFiles/dialogs/ui/dialogs_suggestions.cpp index aa16e370c2..c005c7e4c4 100644 --- a/Telegram/SourceFiles/dialogs/ui/dialogs_suggestions.cpp +++ b/Telegram/SourceFiles/dialogs/ui/dialogs_suggestions.cpp @@ -446,7 +446,7 @@ private: class PopularAppsController final : public Suggestions::ObjectListController { public: - explicit PopularAppsController( + PopularAppsController( not_null window, Fn)> filterOut, rpl::producer<> filterOutRefreshes); @@ -1127,7 +1127,9 @@ PopularAppsController::PopularAppsController( } void PopularAppsController::prepare() { - setupPlainDivider(tr::lng_bot_apps_popular()); + if (_filterOut) { + setupPlainDivider(tr::lng_bot_apps_popular()); + } rpl::single() | rpl::then( std::move(_filterOutRefreshes) ) | rpl::start_with_next([=] { @@ -1163,10 +1165,11 @@ void PopularAppsController::fill() { void PopularAppsController::appendRow(not_null bot) { auto row = std::make_unique(bot); - //if (const auto count = bot->botInfo->activeUsers) { - // row->setCustomStatus( - // tr::lng_bot_status_users(tr::now, lt_count_decimal, count)); - //} + if (bot->isBot()) { + if (!bot->botInfo->activeUsers && !bot->username().isEmpty()) { + row->setCustomStatus('@' + bot->username()); + } + } delegate()->peerListAppendRow(std::move(row)); } @@ -2283,4 +2286,40 @@ RecentPeersList RecentPeersContent(not_null session) { return RecentPeersList{ session->recentPeers().list() }; } +object_ptr StarsExamplesBox( + not_null window) { + auto controller = std::make_unique( + window, + nullptr, + nullptr); + const auto raw = controller.get(); + auto initBox = [=](not_null box) { + box->setTitle(tr::lng_credits_box_history_entry_gift_examples()); + box->addButton(tr::lng_close(), [=] { + box->closeBox(); + }); + + raw->load(); + raw->chosen() | rpl::start_with_next([=](not_null peer) { + if (const auto user = peer->asUser()) { + if (const auto info = user->botInfo.get()) { + if (info->hasMainApp) { + window->session().attachWebView().open({ + .bot = user, + .context = { + .controller = window, + .maySkipConfirmation = true, + }, + .source = InlineBots::WebViewSourceBotProfile(), + }); + return; + } + } + } + window->showPeerInfo(peer); + }, box->lifetime()); + }; + return Box(std::move(controller), std::move(initBox)); +} + } // namespace Dialogs diff --git a/Telegram/SourceFiles/dialogs/ui/dialogs_suggestions.h b/Telegram/SourceFiles/dialogs/ui/dialogs_suggestions.h index cf8b217800..be868b77ab 100644 --- a/Telegram/SourceFiles/dialogs/ui/dialogs_suggestions.h +++ b/Telegram/SourceFiles/dialogs/ui/dialogs_suggestions.h @@ -23,6 +23,7 @@ class Session; } // namespace Main namespace Ui { +class BoxContent; class ElasticScroll; class SettingsSlider; class VerticalLayout; @@ -215,4 +216,7 @@ private: [[nodiscard]] RecentPeersList RecentPeersContent( not_null session); +[[nodiscard]] object_ptr StarsExamplesBox( + not_null window); + } // namespace Dialogs diff --git a/Telegram/SourceFiles/settings/settings_credits_graphics.cpp b/Telegram/SourceFiles/settings/settings_credits_graphics.cpp index 92206e04dc..00950b6c97 100644 --- a/Telegram/SourceFiles/settings/settings_credits_graphics.cpp +++ b/Telegram/SourceFiles/settings/settings_credits_graphics.cpp @@ -759,7 +759,7 @@ void ReceiptCreditsBox( ) | rpl::map([](TextWithEntities text) { return Ui::Text::Link( std::move(text), - tr::lng_credits_box_history_entry_gift_about_url(tr::now)); + u"internal:stars_examples"_q); }); box->addRow(object_ptr>( box,