2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-28 21:18:46 +00:00

Make sure colors are ready for webview.

This commit is contained in:
John Preston 2025-07-23 11:33:49 +04:00
parent b754ad5248
commit dcac27e072
2 changed files with 32 additions and 0 deletions

View File

@ -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() { void WebViewInstance::resolve() {
requestFullBot();
v::match(_source, [&](WebViewSourceButton data) { v::match(_source, [&](WebViewSourceButton data) {
confirmOpen([=] { confirmOpen([=] {
if (data.simple) { if (data.simple) {
@ -1307,6 +1328,10 @@ void WebViewInstance::maybeChooseAndRequestButton(PeerTypes supported) {
} }
void WebViewInstance::show(ShowArgs &&args) { void WebViewInstance::show(ShowArgs &&args) {
if (!_bot->isFullLoaded()) {
_botFullWaitingArgs.emplace(std::move(args));
return;
}
auto title = args.title.isEmpty() auto title = args.title.isEmpty()
? Info::Profile::NameValue(_bot) ? Info::Profile::NameValue(_bot)
: rpl::single(args.title); : rpl::single(args.title);
@ -1373,6 +1398,10 @@ void WebViewInstance::show(ShowArgs &&args) {
void WebViewInstance::showGame() { void WebViewInstance::showGame() {
Expects(v::is<WebViewSourceGame>(_source)); Expects(v::is<WebViewSourceGame>(_source));
if (!_bot->isFullLoaded()) {
_botFullWaitingArgs.emplace();
return;
}
const auto game = v::get<WebViewSourceGame>(_source); const auto game = v::get<WebViewSourceGame>(_source);
_panelUrl = QString::fromUtf8(_button.url); _panelUrl = QString::fromUtf8(_button.url);
_panel = Ui::BotWebView::Show({ _panel = Ui::BotWebView::Show({

View File

@ -231,6 +231,7 @@ public:
private: private:
void resolve(); void resolve();
void requestFullBot();
bool openAppFromBotMenuLink(); bool openAppFromBotMenuLink();
@ -313,6 +314,8 @@ private:
const WebViewButton _button; const WebViewButton _button;
const WebViewSource _source; const WebViewSource _source;
std::optional<ShowArgs> _botFullWaitingArgs;
BotAppData *_app = nullptr; BotAppData *_app = nullptr;
QString _appStartParam; QString _appStartParam;
bool _dataSent = false; bool _dataSent = false;