2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-22 10:17:10 +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() {
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<WebViewSourceGame>(_source));
if (!_bot->isFullLoaded()) {
_botFullWaitingArgs.emplace();
return;
}
const auto game = v::get<WebViewSourceGame>(_source);
_panelUrl = QString::fromUtf8(_button.url);
_panel = Ui::BotWebView::Show({

View File

@ -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<ShowArgs> _botFullWaitingArgs;
BotAppData *_app = nullptr;
QString _appStartParam;
bool _dataSent = false;