From 674bab69f5b1fa078affe9a9f539a4a9cace53a1 Mon Sep 17 00:00:00 2001
From: John Preston <johnprestonmail@gmail.com>
Date: Wed, 13 Sep 2023 09:03:39 +0400
Subject: [PATCH] Send viewport updates in web-apps.

---
 .../ui/chat/attach/attach_bot_webview.cpp            | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/Telegram/SourceFiles/ui/chat/attach/attach_bot_webview.cpp b/Telegram/SourceFiles/ui/chat/attach/attach_bot_webview.cpp
index 97e9bb74b..96546ae00 100644
--- a/Telegram/SourceFiles/ui/chat/attach/attach_bot_webview.cpp
+++ b/Telegram/SourceFiles/ui/chat/attach/attach_bot_webview.cpp
@@ -1050,6 +1050,18 @@ void Panel::processMainButtonMessage(const QJsonObject &args) {
 		return;
 	}
 
+	const auto shown = [&] {
+		return _mainButton && !_mainButton->isHidden();
+	};
+	const auto wasShown = shown();
+	const auto guard = gsl::finally([&] {
+		if (shown() != wasShown) {
+			crl::on_main(this, [=] {
+				sendViewport();
+			});
+		}
+	});
+
 	if (!_mainButton) {
 		if (args["is_visible"].toBool()) {
 			createMainButton();