From dcac27e0729bc3975965a0497154d54b18def49d Mon Sep 17 00:00:00 2001 From: John Preston Date: Wed, 23 Jul 2025 11:33:49 +0400 Subject: [PATCH] Make sure colors are ready for webview. --- .../inline_bots/bot_attach_web_view.cpp | 29 +++++++++++++++++++ .../inline_bots/bot_attach_web_view.h | 3 ++ 2 files changed, 32 insertions(+) diff --git a/Telegram/SourceFiles/inline_bots/bot_attach_web_view.cpp b/Telegram/SourceFiles/inline_bots/bot_attach_web_view.cpp index 8e1af089b1..02304eb965 100644 --- a/Telegram/SourceFiles/inline_bots/bot_attach_web_view.cpp +++ b/Telegram/SourceFiles/inline_bots/bot_attach_web_view.cpp @@ -885,7 +885,28 @@ void WebViewInstance::activate() { } } +void WebViewInstance::requestFullBot() { + if (_bot->isFullLoaded()) { + return; + } + _bot->updateFull(); + _bot->session().changes().peerUpdates( + _bot, + Data::PeerUpdate::Flag::FullInfo + ) | rpl::start_with_next([=] { + if (_botFullWaitingArgs.has_value()) { + auto args = *base::take(_botFullWaitingArgs); + if (args.url.isEmpty()) { + showGame(); + } else { + show(std::move(args)); + } + } + }, _lifetime); +} + void WebViewInstance::resolve() { + requestFullBot(); v::match(_source, [&](WebViewSourceButton data) { confirmOpen([=] { if (data.simple) { @@ -1307,6 +1328,10 @@ void WebViewInstance::maybeChooseAndRequestButton(PeerTypes supported) { } void WebViewInstance::show(ShowArgs &&args) { + if (!_bot->isFullLoaded()) { + _botFullWaitingArgs.emplace(std::move(args)); + return; + } auto title = args.title.isEmpty() ? Info::Profile::NameValue(_bot) : rpl::single(args.title); @@ -1373,6 +1398,10 @@ void WebViewInstance::show(ShowArgs &&args) { void WebViewInstance::showGame() { Expects(v::is(_source)); + if (!_bot->isFullLoaded()) { + _botFullWaitingArgs.emplace(); + return; + } const auto game = v::get(_source); _panelUrl = QString::fromUtf8(_button.url); _panel = Ui::BotWebView::Show({ diff --git a/Telegram/SourceFiles/inline_bots/bot_attach_web_view.h b/Telegram/SourceFiles/inline_bots/bot_attach_web_view.h index e7fe7f281e..7487de27e1 100644 --- a/Telegram/SourceFiles/inline_bots/bot_attach_web_view.h +++ b/Telegram/SourceFiles/inline_bots/bot_attach_web_view.h @@ -231,6 +231,7 @@ public: private: void resolve(); + void requestFullBot(); bool openAppFromBotMenuLink(); @@ -313,6 +314,8 @@ private: const WebViewButton _button; const WebViewSource _source; + std::optional _botFullWaitingArgs; + BotAppData *_app = nullptr; QString _appStartParam; bool _dataSent = false;