Skip to content
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

[HybridApp] Add shortcut support in HybridApp #48780

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/ROUTES.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1424,7 +1424,9 @@ const ROUTES = {
*/
const HYBRID_APP_ROUTES = {
MONEY_REQUEST_CREATE: '/request/new/scan',
MONEY_REQUEST_SUBMIT_CREATE: '/submit/new/scan',
MONEY_REQUEST_CREATE_TAB_SCAN: '/submit/new/scan',
MONEY_REQUEST_CREATE_TAB_MANUAL: '/submit/new/manual',
MONEY_REQUEST_CREATE_TAB_DISTANCE: '/submit/new/distance',
} as const;

export {HYBRID_APP_ROUTES, getUrlWithBackToParam, PUBLIC_SCREENS_ROUTES};
Expand Down
7 changes: 4 additions & 3 deletions src/libs/Navigation/AppNavigator/index.native.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,18 @@ type AppNavigatorProps = {
};

function AppNavigator({authenticated}: AppNavigatorProps) {
const {initialURL} = useContext(InitialURLContext);
const {initialURL, setInitialURL} = useContext(InitialURLContext);

useEffect(() => {
if (!NativeModules.HybridAppModule || !initialURL) {
return;
}

Navigation.isNavigationReady().then(() => {
Navigation.navigate(initialURL);
Navigation.navigate(Navigation.parseHybridAppUrl(initialURL));
setInitialURL(undefined);
});
}, [initialURL]);
}, [initialURL, setInitialURL]);

if (authenticated) {
const AuthScreens = require<ReactComponentModule>('./AuthScreens').default;
Expand Down
18 changes: 1 addition & 17 deletions src/libs/Navigation/AppNavigator/index.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
import React, {lazy, memo, Suspense, useContext, useEffect} from 'react';
import {NativeModules} from 'react-native';
import {InitialURLContext} from '@components/InitialURLContextProvider';
import Navigation from '@libs/Navigation/Navigation';
import ROUTES from '@src/ROUTES';
import React, {lazy, memo, Suspense} from 'react';
import lazyRetry from '@src/utils/lazyRetry';

const AuthScreens = lazy(() => lazyRetry(() => import('./AuthScreens')));
Expand All @@ -14,18 +10,6 @@ type AppNavigatorProps = {
};

function AppNavigator({authenticated}: AppNavigatorProps) {
const {initialURL} = useContext(InitialURLContext);

useEffect(() => {
if (!NativeModules.HybridAppModule || !initialURL || !initialURL.includes(ROUTES.TRANSITION_BETWEEN_APPS)) {
return;
}

Navigation.isNavigationReady().then(() => {
Navigation.navigate(initialURL);
});
}, [initialURL]);

if (authenticated) {
Comment on lines -17 to -28
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❤️

// These are the protected screens and only accessible when an authToken is present
return (
Expand Down
8 changes: 6 additions & 2 deletions src/libs/Navigation/Navigation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,13 @@ function getActiveRouteIndex(stateOrRoute: StateOrRoute, index?: number): number
*/
function parseHybridAppUrl(url: HybridAppRoute | Route): Route {
switch (url) {
case HYBRID_APP_ROUTES.MONEY_REQUEST_CREATE_TAB_MANUAL:
return ROUTES.MONEY_REQUEST_CREATE_TAB_MANUAL.getRoute(CONST.IOU.ACTION.CREATE, CONST.IOU.TYPE.SUBMIT, CONST.IOU.OPTIMISTIC_TRANSACTION_ID, ReportUtils.generateReportID());
case HYBRID_APP_ROUTES.MONEY_REQUEST_CREATE_TAB_DISTANCE:
return ROUTES.MONEY_REQUEST_CREATE_TAB_DISTANCE.getRoute(CONST.IOU.ACTION.CREATE, CONST.IOU.TYPE.SUBMIT, CONST.IOU.OPTIMISTIC_TRANSACTION_ID, ReportUtils.generateReportID());
case HYBRID_APP_ROUTES.MONEY_REQUEST_CREATE:
case HYBRID_APP_ROUTES.MONEY_REQUEST_SUBMIT_CREATE:
return ROUTES.MONEY_REQUEST_CREATE.getRoute(CONST.IOU.ACTION.CREATE, CONST.IOU.TYPE.SUBMIT, CONST.IOU.OPTIMISTIC_TRANSACTION_ID, ReportUtils.generateReportID());
case HYBRID_APP_ROUTES.MONEY_REQUEST_CREATE_TAB_SCAN:
return ROUTES.MONEY_REQUEST_CREATE_TAB_SCAN.getRoute(CONST.IOU.ACTION.CREATE, CONST.IOU.TYPE.SUBMIT, CONST.IOU.OPTIMISTIC_TRANSACTION_ID, ReportUtils.generateReportID());
default:
return url;
}
Expand Down
Loading