Skip to content

Commit 6cbb3d2

Browse files
committed
unify hybrid & standalone deeplinks
1 parent 1b25509 commit 6cbb3d2

3 files changed

Lines changed: 9 additions & 25 deletions

File tree

src/Expensify.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,10 @@ function Expensify() {
203203

204204
// If the app is opened from a deep link, get the reportID (if exists) from the deep link and navigate to the chat report
205205
Linking.getInitialURL().then((url) => {
206+
// We use custom deeplink handler in setup/hybridApp
207+
if (CONFIG.IS_HYBRID_APP) {
208+
return;
209+
}
206210
setInitialUrl(url);
207211
Report.openReportFromDeepLink(url ?? '');
208212
});

src/libs/actions/Report.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3384,7 +3384,7 @@ function openReportFromDeepLink(url: string) {
33843384
// We don't want to navigate to the exitTo route when creating a new workspace from a deep link,
33853385
// because we already handle creating the optimistic policy and navigating to it in App.setUpPoliciesAndNavigate,
33863386
// which is already called when AuthScreens mounts.
3387-
if (url && new URL(url).searchParams.get('exitTo') === ROUTES.WORKSPACE_NEW) {
3387+
if (!CONFIG.IS_HYBRID_APP && url && new URL(url).searchParams.get('exitTo') === ROUTES.WORKSPACE_NEW) {
33883388
return;
33893389
}
33903390

@@ -3405,10 +3405,6 @@ function openReportFromDeepLink(url: string) {
34053405
return;
34063406
}
34073407

3408-
if (isAuthenticated) {
3409-
return;
3410-
}
3411-
34123408
// Check if the report exists in the collection
34133409
const report = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${reportID}`];
34143410
// If the report does not exist, navigate to the last accessed report or Concierge chat
Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,12 @@
1-
import {findFocusedRoute} from '@react-navigation/native';
21
import {Linking} from 'react-native';
3-
import Navigation, {navigationRef} from '@navigation/Navigation';
2+
import Navigation from '@navigation/Navigation';
43
import CONFIG from '@src/CONFIG';
54
import type {Route} from '@src/ROUTES';
6-
import ROUTES from '@src/ROUTES';
7-
import SCREENS from '@src/SCREENS';
5+
import {openReportFromDeepLink} from '@userActions/Report';
86

97
if (CONFIG.IS_HYBRID_APP) {
108
Linking.addEventListener('url', (state) => {
11-
handleHybridUrlNavigation(state.url as Route);
12-
});
13-
}
14-
15-
function handleHybridUrlNavigation(url: Route) {
16-
const parsedUrl = Navigation.parseHybridAppUrl(url);
17-
18-
Navigation.isNavigationReady().then(() => {
19-
if (parsedUrl.startsWith(`/${ROUTES.SHARE_ROOT}`)) {
20-
const focusRoute = findFocusedRoute(navigationRef.getRootState());
21-
if (focusRoute?.name === SCREENS.SHARE.SHARE_DETAILS || focusRoute?.name === SCREENS.SHARE.SUBMIT_DETAILS) {
22-
Navigation.goBack(ROUTES.SHARE_ROOT);
23-
return;
24-
}
25-
}
26-
Navigation.navigate(parsedUrl);
9+
const parsedUrl = Navigation.parseHybridAppUrl(state.url as Route);
10+
openReportFromDeepLink(parsedUrl);
2711
});
2812
}

0 commit comments

Comments
 (0)