Fix opening links from bot inline reply markup.

This commit is contained in:
John Preston 2022-06-18 00:02:27 +04:00
parent 5fe1988d0a
commit b84c876ba2
2 changed files with 12 additions and 4 deletions

View file

@ -24,6 +24,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "history/history_item.h" #include "history/history_item.h"
#include "data/data_user.h" #include "data/data_user.h"
#include "data/data_session.h" #include "data/data_session.h"
#include "window/window_controller.h"
#include "window/window_session_controller.h" #include "window/window_session_controller.h"
namespace { namespace {
@ -118,8 +119,12 @@ void HiddenUrlClickHandler::Open(QString url, QVariant context) {
? QString::fromUtf8(parsedUrl.toEncoded()) ? QString::fromUtf8(parsedUrl.toEncoded())
: ShowEncoded(displayed); : ShowEncoded(displayed);
const auto my = context.value<ClickHandlerContext>(); const auto my = context.value<ClickHandlerContext>();
if (const auto controller = my.sessionWindow.get()) { const auto controller = my.sessionWindow.get();
controller->show( const auto use = controller
? &controller->window()
: Core::App().activeWindow();
if (use) {
use->show(
Ui::MakeConfirmBox({ Ui::MakeConfirmBox({
.text = (tr::lng_open_this_link(tr::now) .text = (tr::lng_open_this_link(tr::now)
+ qsl("\n\n") + qsl("\n\n")

View file

@ -133,10 +133,13 @@ void activateBotCommand(
skipConfirmation = true; skipConfirmation = true;
} }
} }
const auto context = QVariant::fromValue(ClickHandlerContext{
.sessionWindow = sessionController.get(),
});
if (skipConfirmation) { if (skipConfirmation) {
UrlClickHandler::Open(url); UrlClickHandler::Open(url, context);
} else { } else {
HiddenUrlClickHandler::Open(url); HiddenUrlClickHandler::Open(url, context);
} }
} break; } break;