From 5e12cd27df5cc6cc6c09ec363eba308060021337 Mon Sep 17 00:00:00 2001 From: John Preston Date: Fri, 20 Jan 2023 09:33:04 +0400 Subject: [PATCH] Fix web_app_request_[theme|viewport]. Fixes #25752. --- .../SourceFiles/ui/chat/attach/attach_bot_webview.cpp | 11 ++++++++++- .../SourceFiles/ui/chat/attach/attach_bot_webview.h | 1 + 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/Telegram/SourceFiles/ui/chat/attach/attach_bot_webview.cpp b/Telegram/SourceFiles/ui/chat/attach/attach_bot_webview.cpp index f53f8d195..36dab0d4a 100644 --- a/Telegram/SourceFiles/ui/chat/attach/attach_bot_webview.cpp +++ b/Telegram/SourceFiles/ui/chat/attach/attach_bot_webview.cpp @@ -356,7 +356,7 @@ Panel::Panel( postEvent("back_button_pressed"); }, _widget->lifetime()); - rpl::combine( + rpl::merge( style::PaletteChanged(), _themeUpdateForced.events() ) | rpl::filter([=] { @@ -631,6 +631,8 @@ bool Panel::createWebview() { processBackButtonMessage(arguments); } else if (command == "web_app_request_theme") { _themeUpdateForced.fire({}); + } else if (command == "web_app_request_viewport") { + sendViewport(); } else if (command == "web_app_open_tg_link") { openTgLink(arguments); } else if (command == "web_app_open_link") { @@ -675,6 +677,13 @@ postEvent: function(eventType, eventData) { return true; } +void Panel::sendViewport() { + postEvent("viewport_changed", "{ " + "height: window.innerHeight, " + "is_state_stable: true, " + "is_expanded: true }"); +} + void Panel::setTitle(rpl::producer title) { _widget->setTitle(std::move(title)); } diff --git a/Telegram/SourceFiles/ui/chat/attach/attach_bot_webview.h b/Telegram/SourceFiles/ui/chat/attach/attach_bot_webview.h index 0acd1e71e..fe51fd319 100644 --- a/Telegram/SourceFiles/ui/chat/attach/attach_bot_webview.h +++ b/Telegram/SourceFiles/ui/chat/attach/attach_bot_webview.h @@ -100,6 +100,7 @@ private: void createMainButton(); void scheduleCloseWithConfirmation(); void closeWithConfirmation(); + void sendViewport(); using EventData = std::variant; void postEvent(const QString &event);