diff --git a/Telegram/Resources/uwp/AppX/AppxManifest.xml b/Telegram/Resources/uwp/AppX/AppxManifest.xml index 45ec14889..3d4040dd7 100644 --- a/Telegram/Resources/uwp/AppX/AppxManifest.xml +++ b/Telegram/Resources/uwp/AppX/AppxManifest.xml @@ -37,6 +37,9 @@ + + + file(); !file.isEmpty()) { _filesToOpen.append(file); _fileOpenTimer.callOnce(kFileOpenTimeoutMs); - } else if (event->url().scheme() == u"tg"_q) { + } else if (event->url().scheme() == u"tg"_q + || event->url().scheme() == u"tonsite"_q) { const auto url = QString::fromUtf8( event->url().toEncoded().trimmed()); cSetStartUrl(url.mid(0, 8192)); @@ -1084,13 +1085,17 @@ void Application::checkSendPaths() { } void Application::checkStartUrl() { - if (!cStartUrl().isEmpty() - && _lastActivePrimaryWindow - && !_lastActivePrimaryWindow->locked()) { + if (!cStartUrl().isEmpty()) { const auto url = cStartUrl(); - cSetStartUrl(QString()); - if (!openLocalUrl(url, {})) { - cSetStartUrl(url); + if (url.startsWith("tonsite://", Qt::CaseInsensitive)) { + cSetStartUrl(QString()); + iv().showTonSite(url, {}); + } else if (_lastActivePrimaryWindow + && !_lastActivePrimaryWindow->locked()) { + cSetStartUrl(QString()); + if (!openLocalUrl(url, {})) { + cSetStartUrl(url); + } } } } @@ -1798,11 +1803,13 @@ void Application::startShortcuts() { } void Application::RegisterUrlScheme() { + const auto arguments = Launcher::Instance().customWorkingDir() + ? u"-workdir \"%1\""_q.arg(cWorkingDir()) + : QString(); + base::Platform::RegisterUrlScheme(base::Platform::UrlSchemeDescriptor{ .executable = Platform::ExecutablePathForShortcuts(), - .arguments = Launcher::Instance().customWorkingDir() - ? u"-workdir \"%1\""_q.arg(cWorkingDir()) - : QString(), + .arguments = arguments, .protocol = u"tg"_q, .protocolName = u"Telegram Link"_q, .shortAppName = u"tdesktop"_q, @@ -1810,6 +1817,17 @@ void Application::RegisterUrlScheme() { .displayAppName = AppName.utf16(), .displayAppDescription = AppName.utf16(), }); + + base::Platform::RegisterUrlScheme(base::Platform::UrlSchemeDescriptor{ + .executable = Platform::ExecutablePathForShortcuts(), + .arguments = arguments, + .protocol = u"tonsite"_q, + .protocolName = u"TonSite Link"_q, + .shortAppName = u"tdesktop"_q, + .longAppName = QCoreApplication::applicationName(), + .displayAppName = AppName.utf16(), + .displayAppDescription = AppName.utf16(), + }); } bool IsAppLaunched() { diff --git a/Telegram/SourceFiles/iv/iv_controller.cpp b/Telegram/SourceFiles/iv/iv_controller.cpp index 487f9295c..00b645505 100644 --- a/Telegram/SourceFiles/iv/iv_controller.cpp +++ b/Telegram/SourceFiles/iv/iv_controller.cpp @@ -523,12 +523,10 @@ void Controller::createWebview(const Webview::StorageId &storageId) { if (!script.isEmpty()) { _webview->eval(script); } - //} else if (event == u"location_change"_q) { - // _index = object.value("index").toInt(); - // _hash = object.value("hash").toString(); - // _back->toggle( - // (object.value("position").toInt() > 0), - // anim::type::normal); + } else if (event == u"location_change"_q) { + _index = object.value("index").toInt(); + _hash = object.value("hash").toString(); + _webview->refreshNavigationHistoryState(); } }); }); diff --git a/Telegram/SourceFiles/iv/iv_instance.cpp b/Telegram/SourceFiles/iv/iv_instance.cpp index 480d73573..3b327e5a6 100644 --- a/Telegram/SourceFiles/iv/iv_instance.cpp +++ b/Telegram/SourceFiles/iv/iv_instance.cpp @@ -1107,8 +1107,7 @@ void Instance::showTonSite( case Type::OpenPage: case Type::OpenLink: if (urlChecked) { - File::OpenUrl(event.url); - closeAll(); + UrlClickHandler::Open(event.url); } else if (tonsite) { showTonSite(event.url); } diff --git a/Telegram/Telegram.plist b/Telegram/Telegram.plist index b68e2109c..72913e85e 100644 --- a/Telegram/Telegram.plist +++ b/Telegram/Telegram.plist @@ -38,6 +38,7 @@ CFBundleURLSchemes tg + tonsite