Skip to content
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
17 changes: 8 additions & 9 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ import CONFIG from './CONFIG';
import Expensify from './Expensify';
import {CurrentReportIDContextProvider} from './hooks/useCurrentReportID';
import useDefaultDragAndDrop from './hooks/useDefaultDragAndDrop';
import HybridAppHandler from './HybridAppHandler';
import OnyxUpdateManager from './libs/actions/OnyxUpdateManager';
import {ReportAttachmentsProvider} from './pages/home/report/ReportAttachmentsContext';
import type {Route} from './ROUTES';
Expand All @@ -55,6 +54,8 @@ type AppProps = {
url?: Route;
/** Serialized configuration data required to initialize the React Native app (e.g. authentication details) */
hybridAppSettings?: string;
/** A timestamp indicating when the initial properties were last updated, used to detect changes */
timestamp?: string;
};

LogBox.ignoreLogs([
Expand All @@ -70,14 +71,18 @@ const fill = {flex: 1};

const StrictModeWrapper = CONFIG.USE_REACT_STRICT_MODE_IN_DEV ? React.StrictMode : ({children}: {children: React.ReactElement}) => children;

function App({url, hybridAppSettings}: AppProps) {
function App({url, hybridAppSettings, timestamp}: AppProps) {
useDefaultDragAndDrop();
OnyxUpdateManager();

return (
<StrictModeWrapper>
<SplashScreenStateContextProvider>
<InitialURLContextProvider url={url}>
<InitialURLContextProvider
url={url}
hybridAppSettings={hybridAppSettings}
timestamp={timestamp}
>
<GestureHandlerRootView style={fill}>
<ComposeProviders
components={[
Expand Down Expand Up @@ -114,12 +119,6 @@ function App({url, hybridAppSettings}: AppProps) {
>
<CustomStatusBarAndBackground />
<ErrorBoundary errorMessage="NewExpensify crash caught by error boundary">
{CONFIG.IS_HYBRID_APP && (
<HybridAppHandler
url={url}
hybridAppSettings={hybridAppSettings}
/>
)}
<ColorSchemeWrapper>
<Expensify />
</ColorSchemeWrapper>
Expand Down
4 changes: 0 additions & 4 deletions src/Expensify.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -215,10 +215,6 @@ function Expensify() {

// Open chat report from a deep link (only mobile native)
Linking.addEventListener('url', (state) => {
// We use custom deeplink handler in HybridAppHandler
if (CONFIG.IS_HYBRID_APP) {
return;
}
Report.openReportFromDeepLink(state.url);
});

Expand Down
57 changes: 0 additions & 57 deletions src/HybridAppHandler.tsx

This file was deleted.

37 changes: 33 additions & 4 deletions src/components/InitialURLContextProvider.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
import {findFocusedRoute} from '@react-navigation/native';
import React, {createContext, useEffect, useMemo, useState} from 'react';
import type {ReactNode} from 'react';
import {Linking} from 'react-native';
import {signInAfterTransitionFromOldDot} from '@libs/actions/Session';
import Navigation, {navigationRef} from '@navigation/Navigation';
import type {AppProps} from '@src/App';
import CONST from '@src/CONST';
import type {Route} from '@src/ROUTES';
import ROUTES from '@src/ROUTES';
import SCREENS from '@src/SCREENS';
import {useSplashScreenStateContext} from '@src/SplashScreenStateContext';

type InitialUrlContextType = {
initialURL: Route | undefined;
Expand All @@ -20,18 +27,40 @@ type InitialURLContextProviderProps = AppProps & {
children: ReactNode;
};

function InitialURLContextProvider({children, url}: InitialURLContextProviderProps) {
function InitialURLContextProvider({children, url, hybridAppSettings, timestamp}: InitialURLContextProviderProps) {
const [initialURL, setInitialURL] = useState<Route | undefined>();
const {splashScreenState, setSplashScreenState} = useSplashScreenStateContext();

useEffect(() => {
if (url) {
setInitialURL(url);
if (url && hybridAppSettings) {
signInAfterTransitionFromOldDot(hybridAppSettings).then(() => {
setInitialURL(url);

const parsedUrl = Navigation.parseHybridAppUrl(url);

Navigation.isNavigationReady().then(() => {
if (parsedUrl.startsWith(`/${ROUTES.SHARE_ROOT}`)) {
const focusRoute = findFocusedRoute(navigationRef.getRootState());
if (focusRoute?.name === SCREENS.SHARE.SHARE_DETAILS || focusRoute?.name === SCREENS.SHARE.SUBMIT_DETAILS) {
Navigation.goBack(ROUTES.SHARE_ROOT);
return;
}
}
Navigation.navigate(parsedUrl);
});

if (splashScreenState === CONST.BOOT_SPLASH_STATE.HIDDEN) {
return;
}
setSplashScreenState(CONST.BOOT_SPLASH_STATE.READY_TO_BE_HIDDEN);
});
return;
}
Linking.getInitialURL().then((initURL) => {
setInitialURL(initURL as Route);
});
}, [url]);
// eslint-disable-next-line react-compiler/react-compiler, react-hooks/exhaustive-deps
}, [url, hybridAppSettings, timestamp]);

const initialUrlContext = useMemo(
() => ({
Expand Down
Loading