From da1ac9d417e19b838c3d733b7a1bb4693a9ca6c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=2E=20Diego=20Rodr=C3=ADguez=20Royo?= Date: Tue, 27 Feb 2024 18:34:37 +0100 Subject: [PATCH 1/2] Try opening on native app --- src/entrypoints/my-redirect.ts | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/entrypoints/my-redirect.ts b/src/entrypoints/my-redirect.ts index 62b48d41..370326d0 100644 --- a/src/entrypoints/my-redirect.ts +++ b/src/entrypoints/my-redirect.ts @@ -5,7 +5,7 @@ import { extractSearchParamsObject, } from "../util/search-params"; import { getInstanceUrl } from "../data/instance_info"; -import { Redirect } from "../const"; +import { MOBILE_URL, Redirect } from "../const"; import { svgPencil } from "../components/svg-pencil"; import { isMobile } from "../data/is_mobile"; import { validateParam } from "../util/validate"; @@ -37,6 +37,12 @@ const createRedirectParams = (): string => { let changingInstance = false; +const getRedirectUrl = (baseUrl: string, params) => { + return window.redirect.redirect === "oauth" + ? `${baseUrl}/auth/external/callback${params}` + : `${baseUrl}/_my_redirect/${window.redirect.redirect}${params}`; +}; + const render = (showTroubleshooting: boolean) => { const instanceUrl = getInstanceUrl(); @@ -53,6 +59,12 @@ const render = (showTroubleshooting: boolean) => { return; } + if (!isMobile) { + //Try opening on the native app + const redirectUrlToNativeApp = getRedirectUrl(MOBILE_URL, params); + document.location.assign(redirectUrlToNativeApp); + } + const changeUrl = `/redirect/_change/?redirect=${encodeURIComponent( window.redirect.redirect + "/" + params )}`; @@ -63,10 +75,7 @@ const render = (showTroubleshooting: boolean) => { return; } - const redirectUrl = - window.redirect.redirect === "oauth" - ? `${instanceUrl}/auth/external/callback${params}` - : `${instanceUrl}/_my_redirect/${window.redirect.redirect}${params}`; + const redirectUrl = getRedirectUrl(instanceUrl, params); const openLink = document.querySelector(".open-link") as HTMLElement; openLink.outerHTML = ` From d1a8742a7317117e020e82d35777eecb7a610113 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=2E=20Diego=20Rodr=C3=ADguez=20Royo?= Date: Sat, 15 Mar 2025 11:22:29 +0000 Subject: [PATCH 2/2] Open automatically the redirect link to the native app only in Windows --- src/entrypoints/my-redirect.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/entrypoints/my-redirect.ts b/src/entrypoints/my-redirect.ts index 93239158..c8d020b1 100644 --- a/src/entrypoints/my-redirect.ts +++ b/src/entrypoints/my-redirect.ts @@ -62,8 +62,8 @@ const render = (showTroubleshooting: boolean) => { return; } - if (!isMobile) { - //Try opening on the native app + if (!isMobile && navigator.userAgent.includes("Windows")) { + // Try opening the native app on Windows const redirectUrlToNativeApp = getRedirectUrl(MOBILE_URL, params); document.location.assign(redirectUrlToNativeApp); }