From e74021fbc9eb073a5b5c7d364986b7bdd1ae0f1c Mon Sep 17 00:00:00 2001 From: John Preston Date: Wed, 13 Sep 2023 20:48:51 +0400 Subject: [PATCH] Show "Open Bot" button for main menu apps. --- .../inline_bots/bot_attach_web_view.cpp | 15 +++++++++++---- .../SourceFiles/inline_bots/bot_attach_web_view.h | 3 ++- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/Telegram/SourceFiles/inline_bots/bot_attach_web_view.cpp b/Telegram/SourceFiles/inline_bots/bot_attach_web_view.cpp index fca245fed..c8c9ec316 100644 --- a/Telegram/SourceFiles/inline_bots/bot_attach_web_view.cpp +++ b/Telegram/SourceFiles/inline_bots/bot_attach_web_view.cpp @@ -1151,8 +1151,13 @@ void AttachWebView::requestSimple(const WebViewButton &button) { )).done([=](const MTPSimpleWebViewResult &result) { _requestId = 0; result.match([&](const MTPDsimpleWebViewResultUrl &data) { - const auto queryId = uint64(); - show(queryId, qs(data.vurl()), button.text); + show( + uint64(), + qs(data.vurl()), + button.text, + false, + nullptr, + button.fromMainMenu); }); }).fail([=](const MTP::Error &error) { _requestId = 0; @@ -1396,7 +1401,8 @@ void AttachWebView::show( const QString &url, const QString &buttonText, bool allowClipboardRead, - const BotAppData *app) { + const BotAppData *app, + bool fromMainMenu) { Expects(_bot != nullptr && _context != nullptr); auto title = Info::Profile::NameValue(_bot); @@ -1413,7 +1419,8 @@ void AttachWebView::show( && !attached->inactive && attached->hasSettings); const auto hasOpenBot = !_context - || (_bot != _context->action.history->peer); + || (_bot != _context->action.history->peer) + || fromMainMenu; const auto hasRemoveFromMenu = !app && (attached != end(_attachBots)) && (!attached->inactive || attached->inMainMenu); diff --git a/Telegram/SourceFiles/inline_bots/bot_attach_web_view.h b/Telegram/SourceFiles/inline_bots/bot_attach_web_view.h index c0216b943..f08f68027 100644 --- a/Telegram/SourceFiles/inline_bots/bot_attach_web_view.h +++ b/Telegram/SourceFiles/inline_bots/bot_attach_web_view.h @@ -215,7 +215,8 @@ private: const QString &url, const QString &buttonText = QString(), bool allowClipboardRead = false, - const BotAppData *app = nullptr); + const BotAppData *app = nullptr, + bool fromMainMenu = false); void confirmAddToMenu( AttachWebViewBot bot, Fn callback = nullptr);