diff --git a/Telegram/SourceFiles/inline_bots/bot_attach_web_view.cpp b/Telegram/SourceFiles/inline_bots/bot_attach_web_view.cpp index e99f48e1b..29842290b 100644 --- a/Telegram/SourceFiles/inline_bots/bot_attach_web_view.cpp +++ b/Telegram/SourceFiles/inline_bots/bot_attach_web_view.cpp @@ -555,14 +555,16 @@ Webview::ThemeParams AttachWebView::botThemeParams() { return Window::Theme::WebViewParams(); } -bool AttachWebView::botHandleLocalUri(QString uri) { +bool AttachWebView::botHandleLocalUri(QString uri, bool keepOpen) { const auto local = Core::TryConvertUrlToLocal(uri); if (uri == local || Core::InternalPassportLink(local)) { return local.startsWith(u"tg://"_q); } else if (!local.startsWith(u"tg://"_q, Qt::CaseInsensitive)) { return false; } - botClose(); + if (!keepOpen) { + botClose(); + } crl::on_main([=, shownUrl = _lastShownUrl] { const auto variant = QVariant::fromValue(ClickHandlerContext{ .attachBotWebviewUrl = shownUrl, diff --git a/Telegram/SourceFiles/inline_bots/bot_attach_web_view.h b/Telegram/SourceFiles/inline_bots/bot_attach_web_view.h index 67b1bead4..ce8a167e4 100644 --- a/Telegram/SourceFiles/inline_bots/bot_attach_web_view.h +++ b/Telegram/SourceFiles/inline_bots/bot_attach_web_view.h @@ -159,7 +159,7 @@ private: Webview::ThemeParams botThemeParams() override; - bool botHandleLocalUri(QString uri) override; + bool botHandleLocalUri(QString uri, bool keepOpen) override; void botHandleInvoice(QString slug) override; void botHandleMenuButton(Ui::BotWebView::MenuButton button) override; void botSendData(QByteArray data) override; diff --git a/Telegram/SourceFiles/ui/chat/attach/attach_bot_webview.cpp b/Telegram/SourceFiles/ui/chat/attach/attach_bot_webview.cpp index 6eff646ae..104ed02b6 100644 --- a/Telegram/SourceFiles/ui/chat/attach/attach_bot_webview.cpp +++ b/Telegram/SourceFiles/ui/chat/attach/attach_bot_webview.cpp @@ -658,7 +658,7 @@ bool Panel::createWebview(const Webview::ThemeParams ¶ms) { }); raw->setNavigationStartHandler([=](const QString &uri, bool newWindow) { - if (_delegate->botHandleLocalUri(uri)) { + if (_delegate->botHandleLocalUri(uri, false)) { return false; } else if (newWindow) { return true; @@ -743,16 +743,17 @@ void Panel::switchInlineQueryMessage(const QJsonObject &args) { void Panel::openTgLink(const QJsonObject &args) { if (args.isEmpty()) { + LOG(("BotWebView Error: Bad arguments in 'web_app_open_tg_link'.")); _delegate->botClose(); return; } const auto path = args["path_full"].toString(); if (path.isEmpty()) { - LOG(("BotWebView Error: Bad 'path_full' in openTgLink.")); + LOG(("BotWebView Error: Bad 'path_full' in 'web_app_open_tg_link'.")); _delegate->botClose(); return; } - _delegate->botHandleLocalUri("https://t.me" + path); + _delegate->botHandleLocalUri("https://t.me" + path, true); } void Panel::openExternalLink(const QJsonObject &args) { diff --git a/Telegram/SourceFiles/ui/chat/attach/attach_bot_webview.h b/Telegram/SourceFiles/ui/chat/attach/attach_bot_webview.h index 28ea96cc2..20a9a4f72 100644 --- a/Telegram/SourceFiles/ui/chat/attach/attach_bot_webview.h +++ b/Telegram/SourceFiles/ui/chat/attach/attach_bot_webview.h @@ -54,7 +54,7 @@ struct CustomMethodRequest { class Delegate { public: virtual Webview::ThemeParams botThemeParams() = 0; - virtual bool botHandleLocalUri(QString uri) = 0; + virtual bool botHandleLocalUri(QString uri, bool keepOpen) = 0; virtual void botHandleInvoice(QString slug) = 0; virtual void botHandleMenuButton(MenuButton button) = 0; virtual void botSendData(QByteArray data) = 0;