From f986a7917cb88479fc6b0c3f13bba924402a5b24 Mon Sep 17 00:00:00 2001 From: Puneet Lath Date: Thu, 30 May 2024 12:32:06 -0400 Subject: [PATCH] Merge pull request #42847 from Expensify/techievivek_revert_41764 Revert "Merge pull request #41764 from software-mansion-labs:fix-init-url-hybrid (cherry picked from commit a09a12b412dc1abd75d56725f3c702bb1d5539a1) --- src/components/InitialURLContextProvider.tsx | 14 ++++++++++++-- .../settings/ExitSurvey/ExitSurveyConfirmPage.tsx | 1 - 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/components/InitialURLContextProvider.tsx b/src/components/InitialURLContextProvider.tsx index 710f045ede4e..a3df93844ca9 100644 --- a/src/components/InitialURLContextProvider.tsx +++ b/src/components/InitialURLContextProvider.tsx @@ -1,5 +1,6 @@ -import React, {createContext} from 'react'; +import React, {createContext, useEffect, useState} from 'react'; import type {ReactNode} from 'react'; +import {Linking} from 'react-native'; import type {Route} from '@src/ROUTES'; /** Initial url that will be opened when NewDot is embedded into Hybrid App. */ @@ -14,7 +15,16 @@ type InitialURLContextProviderProps = { }; function InitialURLContextProvider({children, url}: InitialURLContextProviderProps) { - return {children}; + const [initialURL, setInitialURL] = useState(url); + useEffect(() => { + if (initialURL) { + return; + } + Linking.getInitialURL().then((initURL) => { + setInitialURL(initURL as Route); + }); + }, [initialURL]); + return {children}; } InitialURLContextProvider.displayName = 'InitialURLContextProvider'; diff --git a/src/pages/settings/ExitSurvey/ExitSurveyConfirmPage.tsx b/src/pages/settings/ExitSurvey/ExitSurveyConfirmPage.tsx index 7507e1015f86..672dbbb91069 100644 --- a/src/pages/settings/ExitSurvey/ExitSurveyConfirmPage.tsx +++ b/src/pages/settings/ExitSurvey/ExitSurveyConfirmPage.tsx @@ -87,7 +87,6 @@ function ExitSurveyConfirmPage({exitReason, isLoading, route, navigation}: ExitS ExitSurvey.switchToOldDot(); if (NativeModules.HybridAppModule) { - Navigation.resetToHome(); NativeModules.HybridAppModule.closeReactNativeApp(); return; }