-
Notifications
You must be signed in to change notification settings - Fork 4k
fix: navigate to Concierge chat after login from Concierge deep link on web #96387
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
x-dev90
wants to merge
32
commits into
Expensify:main
Choose a base branch
from
x-dev90:fix/web-concierge-deep-link-login-navigation
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
32 commits
Select commit
Hold shift + click to select a range
c307c84
fix: navigate to Concierge chat after login from deep link on web
x-dev90 f870138
Fix missing pending Concierge deep link helper
x-dev90 9f44d64
Merge branch 'main' into fix/web-concierge-deep-link-login-navigation
x-dev90 b972082
Add comment for pending Concierge intent helper
x-dev90 0ceaa6f
Merge branch 'main' into fix/web-concierge-deep-link-login-navigation
x-dev90 e6df449
fix: persist pending Concierge deep link across reloads
x-dev90 91e65ec
fix: use type import for pending Concierge reload test
x-dev90 537a2e3
Merge branch 'main' into fix/web-concierge-deep-link-login-navigation
x-dev90 eea9b8d
Merge branch 'main' into fix/web-concierge-deep-link-login-navigation
x-dev90 3f4a0eb
Fix Concierge onboarding deep link persistence and cancellation
x-dev90 74735c9
Fix lint-safe Concierge deep link reload detection
x-dev90 c2cf6b2
Merge branch 'main' into fix/web-concierge-deep-link-login-navigation
x-dev90 71c10c7
Fix Concierge deep-link intent through onboarding edge cases
x-dev90 e181a8c
Fix Concierge deep link after onboarding refresh flows
x-dev90 b66c1b6
Merge branch 'main' into fix/web-concierge-deep-link-login-navigation
x-dev90 a5eb8b0
Merge branch 'main' into fix/web-concierge-deep-link-login-navigation
x-dev90 60d03b2
Merge branch 'main' into fix/web-concierge-deep-link-login-navigation
x-dev90 ee4b83b
Fix onboarding navigation tests after merge updates
x-dev90 9dfe564
Fix onboarding navigation test after merge updates
x-dev90 5198605
Merge branch 'main' into fix/web-concierge-deep-link-login-navigation
x-dev90 09f0907
Merge branch 'main' into fix/web-concierge-deep-link-login-navigation
x-dev90 10a4afe
Merge branch 'main' into fix/web-concierge-deep-link-login-navigation
x-dev90 39af2f4
Merge branch 'main' into fix/web-concierge-deep-link-login-navigation
x-dev90 c1d2933
Fix Concierge deep link before onboarding modal unmounts
x-dev90 2e8af74
Fix two-tab Concierge onboarding intent cancellation
x-dev90 e2adfa8
Fix unsafe finally return in Track onboarding navigation
x-dev90 033c831
fix: prevent Concierge flash after root signup onboarding
x-dev90 6f7abdb
fix: reset Escape dismiss state before onboarding deep-link navigation
x-dev90 ba32e0f
Merge branch 'main' into fix/web-concierge-deep-link-login-navigation
x-dev90 4701899
fix: keep Concierge deep link focused through onboarding
x-dev90 2302dca
fix: make Track onboarding cleanup lint-safe
x-dev90 7b7175b
Merge branch 'main' into fix/web-concierge-deep-link-login-navigation
x-dev90 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,144 @@ | ||
| import ROUTES from '@src/ROUTES'; | ||
|
|
||
| import isPublicScreenRoute from './isPublicScreenRoute'; | ||
| import normalizePath from './Navigation/helpers/normalizePath'; | ||
|
|
||
| /** | ||
| * Tracks whether a logged-out user opened a /concierge deep link so the app can | ||
| * route them to Concierge after sign-up/onboarding. sessionStorage keeps the | ||
| * tab-scoped intent across page reloads while sign-out/consume paths clear it. | ||
| */ | ||
| const PENDING_CONCIERGE_DEEP_LINK_STORAGE_KEY = 'PENDING_CONCIERGE_DEEP_LINK'; | ||
| const LEGACY_PERFORMANCE_NAVIGATION_KEY = 'navigation'; | ||
| const LEGACY_PERFORMANCE_NAVIGATION_TYPE_KEY = 'type'; | ||
| const LEGACY_PERFORMANCE_NAVIGATION_TYPE_RELOAD = 1; | ||
| let hasPendingConciergeDeepLink = false; | ||
|
x-dev90 marked this conversation as resolved.
|
||
|
|
||
| function getSessionStorage() { | ||
| try { | ||
| return typeof window === 'undefined' ? undefined : window.sessionStorage; | ||
| } catch { | ||
| return undefined; | ||
| } | ||
| } | ||
|
|
||
| function getStoredValue(key: string, getStorage: () => Storage | undefined) { | ||
| try { | ||
| return getStorage()?.getItem(key); | ||
| } catch { | ||
| return undefined; | ||
| } | ||
| } | ||
|
|
||
| function setStoredValue(key: string, value: string, getStorage: () => Storage | undefined) { | ||
| try { | ||
| getStorage()?.setItem(key, value); | ||
| } catch { | ||
| // Ignore storage failures and keep the in-memory intent for the current page lifecycle. | ||
| } | ||
| } | ||
|
|
||
| function clearStoredValue(key: string, getStorage: () => Storage | undefined) { | ||
| try { | ||
| getStorage()?.removeItem(key); | ||
| } catch { | ||
| // Ignore storage failures since clearing the in-memory flag is still enough for this page lifecycle. | ||
| } | ||
| } | ||
|
|
||
| function hasStoredFlag(key: string) { | ||
| return getStoredValue(key, getSessionStorage) === 'true'; | ||
| } | ||
|
|
||
| function setStoredFlag(key: string) { | ||
| setStoredValue(key, 'true', getSessionStorage); | ||
| } | ||
|
|
||
| function clearStoredFlag(key: string) { | ||
| clearStoredValue(key, getSessionStorage); | ||
| } | ||
|
|
||
| function hasPendingConciergeDeepLinkFlag() { | ||
| return hasPendingConciergeDeepLink || hasStoredFlag(PENDING_CONCIERGE_DEEP_LINK_STORAGE_KEY); | ||
| } | ||
|
|
||
| function clearPendingConciergeDeepLink() { | ||
| hasPendingConciergeDeepLink = false; | ||
| clearStoredFlag(PENDING_CONCIERGE_DEEP_LINK_STORAGE_KEY); | ||
| } | ||
|
|
||
| function setPendingConciergeDeepLink() { | ||
| hasPendingConciergeDeepLink = true; | ||
| setStoredFlag(PENDING_CONCIERGE_DEEP_LINK_STORAGE_KEY); | ||
| } | ||
|
|
||
| function isRecord(value: unknown): value is Record<string, unknown> { | ||
| return typeof value === 'object' && value !== null; | ||
| } | ||
|
|
||
| function isBrowserReload() { | ||
| try { | ||
| // A browser refresh during signup can replay root/home even though the stored Concierge intent is still valid. | ||
| const performance = typeof window === 'undefined' ? undefined : window.performance; | ||
| const navigationEntries = performance?.getEntriesByType?.('navigation') ?? []; | ||
| if (navigationEntries.some((entry) => 'type' in entry && entry.type === 'reload')) { | ||
| return true; | ||
| } | ||
|
|
||
| // Some web runtimes only expose the deprecated navigation API, so read it indirectly to keep the fallback without triggering deprecated API lint. | ||
| const legacyNavigation: unknown = performance ? Reflect.get(performance, LEGACY_PERFORMANCE_NAVIGATION_KEY) : undefined; | ||
| return isRecord(legacyNavigation) && legacyNavigation[LEGACY_PERFORMANCE_NAVIGATION_TYPE_KEY] === LEGACY_PERFORMANCE_NAVIGATION_TYPE_RELOAD; | ||
| } catch { | ||
| return false; | ||
| } | ||
| } | ||
|
|
||
| function getNormalizedRouteWithoutParams(route: string) { | ||
| const [routeWithoutParams] = normalizePath(route).split(/[?#]/, 1); | ||
| return routeWithoutParams.replace(/\/$/, '') || '/'; | ||
| } | ||
|
|
||
| function isOnboardingRoute(normalizedRoute: string) { | ||
| // Onboarding URLs are generated by the guided setup flow, so they should not replace the original signup deep-link intent. | ||
| return normalizedRoute === normalizePath(ROUTES.ONBOARDING_ROOT.route) || normalizedRoute.startsWith(`${normalizePath(ROUTES.ONBOARDING_ROOT.route)}/`); | ||
| } | ||
|
|
||
| function setPendingHomeDeepLinkIfNoPendingConcierge() { | ||
| // Startup/linking can emit ambiguous root/home signals, so avoid replacing an explicit /concierge intent. | ||
| if (hasPendingConciergeDeepLinkFlag()) { | ||
| return; | ||
| } | ||
| clearPendingConciergeDeepLink(); | ||
| } | ||
|
|
||
| // Keep pending signup deep-link intent consistent across initial URL handling and later Linking URL events. | ||
| function updatePendingConciergeDeepLinkForRoute(route: string, isAuthenticated: boolean) { | ||
| const normalizedRoute = getNormalizedRouteWithoutParams(route); | ||
| const routeForPublicScreen = normalizedRoute === '/' ? '' : normalizedRoute.slice(1); | ||
|
|
||
| if (isAuthenticated) { | ||
| if (normalizedRoute === '/' || normalizedRoute === normalizePath(ROUTES.HOME) || isOnboardingRoute(normalizedRoute)) { | ||
| return; | ||
| } | ||
| if (normalizedRoute !== normalizePath(ROUTES.CONCIERGE) && !isPublicScreenRoute(routeForPublicScreen)) { | ||
| clearPendingConciergeDeepLink(); | ||
| } | ||
| return; | ||
| } | ||
|
|
||
| if (normalizedRoute === normalizePath(ROUTES.CONCIERGE)) { | ||
| setPendingConciergeDeepLink(); | ||
| } else if ((normalizedRoute === '/' && isBrowserReload()) || normalizedRoute === normalizePath(ROUTES.HOME)) { | ||
| setPendingHomeDeepLinkIfNoPendingConcierge(); | ||
| } else if (!isPublicScreenRoute(routeForPublicScreen)) { | ||
| clearPendingConciergeDeepLink(); | ||
| } | ||
| } | ||
|
|
||
| function consumePendingConciergeDeepLink() { | ||
| const shouldNavigateToConcierge = hasPendingConciergeDeepLinkFlag(); | ||
| clearPendingConciergeDeepLink(); | ||
| return shouldNavigateToConcierge; | ||
| } | ||
|
|
||
| export {setPendingConciergeDeepLink, setPendingHomeDeepLinkIfNoPendingConcierge, updatePendingConciergeDeepLinkForRoute, consumePendingConciergeDeepLink, clearPendingConciergeDeepLink}; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.