From 3001464f6b2b1e852ca7aa3f02e2baf88e662b23 Mon Sep 17 00:00:00 2001 From: John Preston Date: Wed, 14 Aug 2024 16:49:26 +0200 Subject: [PATCH] Show error on webapp share-to-story. --- Telegram/Resources/langs/lang.strings | 1 + .../ui/chat/attach/attach_bot_webview.cpp | 15 +++++++++++++++ .../ui/chat/attach/attach_bot_webview.h | 1 + 3 files changed, 17 insertions(+) diff --git a/Telegram/Resources/langs/lang.strings b/Telegram/Resources/langs/lang.strings index 0f97e1451..a62ee5e8b 100644 --- a/Telegram/Resources/langs/lang.strings +++ b/Telegram/Resources/langs/lang.strings @@ -3249,6 +3249,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL "lng_bot_add_to_side_menu" = "{bot} asks your permission to be added as an option to your main menu so you can access it any time."; "lng_bot_add_to_side_menu_done" = "Bot added to the main menu."; "lng_bot_no_scan_qr" = "QR Codes for bots are not supported on Desktop. Please use one of Telegram's mobile apps."; +"lng_bot_no_share_story" = "Sharing to Stories is not supported on Desktop. Please use one of Telegram's mobile apps."; "lng_bot_click_to_start" = "Click here to use this bot."; "lng_bot_status_users#one" = "{count} user"; "lng_bot_status_users#other" = "{count} users"; diff --git a/Telegram/SourceFiles/ui/chat/attach/attach_bot_webview.cpp b/Telegram/SourceFiles/ui/chat/attach/attach_bot_webview.cpp index 6a083f41e..2e8f3f345 100644 --- a/Telegram/SourceFiles/ui/chat/attach/attach_bot_webview.cpp +++ b/Telegram/SourceFiles/ui/chat/attach/attach_bot_webview.cpp @@ -699,6 +699,8 @@ bool Panel::createWebview(const Webview::ThemeParams ¶ms) { openPopup(arguments); } else if (command == "web_app_open_scan_qr_popup") { openScanQrPopup(arguments); + } else if (command == "web_app_share_to_story") { + openShareStory(arguments); } else if (command == "web_app_request_write_access") { requestWriteAccess(); } else if (command == "web_app_request_phone") { @@ -936,6 +938,19 @@ void Panel::openScanQrPopup(const QJsonObject &args) { }); } +void Panel::openShareStory(const QJsonObject &args) { + const auto widget = _webview->window.widget(); + [[maybe_unused]] const auto ok = Webview::ShowBlockingPopup({ + .parent = widget ? widget->window() : nullptr, + .text = tr::lng_bot_no_share_story(tr::now), + .buttons = { { + .id = "ok", + .text = tr::lng_box_ok(tr::now), + .type = Webview::PopupArgs::Button::Type::Ok, + }}, + }); +} + void Panel::requestWriteAccess() { if (_inBlockingRequest) { replyRequestWriteAccess(false); diff --git a/Telegram/SourceFiles/ui/chat/attach/attach_bot_webview.h b/Telegram/SourceFiles/ui/chat/attach/attach_bot_webview.h index 33ad0ad23..0c4259baa 100644 --- a/Telegram/SourceFiles/ui/chat/attach/attach_bot_webview.h +++ b/Telegram/SourceFiles/ui/chat/attach/attach_bot_webview.h @@ -135,6 +135,7 @@ private: void openInvoice(const QJsonObject &args); void openPopup(const QJsonObject &args); void openScanQrPopup(const QJsonObject &args); + void openShareStory(const QJsonObject &args); void requestWriteAccess(); void replyRequestWriteAccess(bool allowed); void requestPhone();