mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-17 22:57:11 +02:00
Don't close webview after 'web_app_open_tg_link'.
This commit is contained in:
parent
e59a60b3b5
commit
7f9461820b
4 changed files with 10 additions and 7 deletions
|
@ -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,
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Add table
Reference in a new issue