From adfd63223f911ed6dd8d7d94f197ed5d7284f35d Mon Sep 17 00:00:00 2001 From: Bernhard Owen Josephus Date: Thu, 3 Oct 2024 16:14:36 +0800 Subject: [PATCH] don't promp to open in desktop if user is coming from desktop --- src/components/DeeplinkWrapper/index.website.tsx | 5 +++++ src/libs/actions/Link.ts | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/components/DeeplinkWrapper/index.website.tsx b/src/components/DeeplinkWrapper/index.website.tsx index b395eb12c5fe..6f6562f97c17 100644 --- a/src/components/DeeplinkWrapper/index.website.tsx +++ b/src/components/DeeplinkWrapper/index.website.tsx @@ -22,6 +22,11 @@ function promptToOpenInDesktopApp(initialUrl = '') { // 2. There may be non-idempotent operations (e.g. create a new workspace), which obviously should not be executed again in the desktop app. // So we need to wait until after sign-in and navigation are complete before starting the deeplink redirect. if (Str.startsWith(window.location.pathname, Str.normalizeUrl(ROUTES.TRANSITION_BETWEEN_APPS))) { + const params = new URLSearchParams(window.location.search); + // If the user is redirected from the desktop app, don't prompt the user to open in desktop. + if (params.get('referrer') === 'desktop') { + return; + } App.beginDeepLinkRedirectAfterTransition(); } else { // Match any magic link (/v//<6 digit code>) diff --git a/src/libs/actions/Link.ts b/src/libs/actions/Link.ts index 886f8b06fc6f..13fcea0df85d 100644 --- a/src/libs/actions/Link.ts +++ b/src/libs/actions/Link.ts @@ -195,7 +195,8 @@ function buildURLWithAuthToken(url: string, shortLivedAuthToken?: string) { const emailParam = `email=${encodeURIComponent(currentUserEmail)}`; const exitTo = `exitTo=${url}`; const accountID = `accountID=${currentUserAccountID}`; - const paramsArray = [accountID, emailParam, authTokenParam, exitTo]; + const referrer = 'referrer=desktop'; + const paramsArray = [accountID, emailParam, authTokenParam, exitTo, referrer]; const params = paramsArray.filter(Boolean).join('&'); return `${CONFIG.EXPENSIFY.NEW_EXPENSIFY_URL}transition?${params}`;