From dc6651ed9778efa25165da309f163c98918dad2c Mon Sep 17 00:00:00 2001 From: Mateusz Rajski Date: Wed, 6 Nov 2024 14:23:54 +0100 Subject: [PATCH] Unify how we pass data on both platforms --- src/App.tsx | 3 +-- src/components/InitialURLContextProvider.tsx | 3 +-- src/libs/actions/HybridApp/index.ts | 6 +++++- src/libs/actions/Session/index.ts | 7 ++++--- 4 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/App.tsx b/src/App.tsx index 64d41f8b70d7..47c09c84f8de 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -35,7 +35,6 @@ import CONFIG from './CONFIG'; import Expensify from './Expensify'; import useDefaultDragAndDrop from './hooks/useDefaultDragAndDrop'; import {ReportIDsContextProvider} from './hooks/useReportIDs'; -import type HybridAppSettings from './libs/actions/HybridApp'; import OnyxUpdateManager from './libs/actions/OnyxUpdateManager'; import {ReportAttachmentsProvider} from './pages/home/report/ReportAttachmentsContext'; import type {Route} from './ROUTES'; @@ -43,7 +42,7 @@ import {SplashScreenStateContextProvider} from './SplashScreenStateContext'; type AppProps = { url?: Route; - hybridAppSettings?: HybridAppSettings; + hybridAppSettings?: string; }; LogBox.ignoreLogs([ diff --git a/src/components/InitialURLContextProvider.tsx b/src/components/InitialURLContextProvider.tsx index 92858cdaebba..cf5094e0fcc8 100644 --- a/src/components/InitialURLContextProvider.tsx +++ b/src/components/InitialURLContextProvider.tsx @@ -1,7 +1,6 @@ import React, {createContext, useEffect, useMemo, useState} from 'react'; import type {ReactNode} from 'react'; import {Linking} from 'react-native'; -import type HybridAppSettings from '@libs/actions/HybridApp'; import {signInAfterTransitionFromOldDot} from '@libs/actions/Session'; import CONST from '@src/CONST'; import type {Route} from '@src/ROUTES'; @@ -21,7 +20,7 @@ const InitialURLContext = createContext({ type InitialURLContextProviderProps = { url?: Route; - hybridAppSettings?: HybridAppSettings; + hybridAppSettings?: string; /** Children passed to the context provider */ children: ReactNode; diff --git a/src/libs/actions/HybridApp/index.ts b/src/libs/actions/HybridApp/index.ts index 9995ac4ef5d4..bb0b61ec9845 100644 --- a/src/libs/actions/HybridApp/index.ts +++ b/src/libs/actions/HybridApp/index.ts @@ -1,3 +1,7 @@ import type HybridAppSettings from './types'; -export default HybridAppSettings; +function parseHybridAppSettings(hybridAppSettings: string): HybridAppSettings { + return JSON.parse(hybridAppSettings) as HybridAppSettings; +} + +export default parseHybridAppSettings; diff --git a/src/libs/actions/Session/index.ts b/src/libs/actions/Session/index.ts index bb2332c8c99b..27c530ccb397 100644 --- a/src/libs/actions/Session/index.ts +++ b/src/libs/actions/Session/index.ts @@ -5,7 +5,7 @@ import {InteractionManager, Linking, NativeModules} from 'react-native'; import type {OnyxEntry, OnyxUpdate} from 'react-native-onyx'; import Onyx from 'react-native-onyx'; import type {ValueOf} from 'type-fest'; -import type HybridAppSettings from '@libs/actions/HybridApp'; +import parseHybridAppSettings from '@libs/actions/HybridApp'; import * as PersistedRequests from '@libs/actions/PersistedRequests'; import * as API from '@libs/API'; import type { @@ -480,8 +480,9 @@ function signUpUser() { API.write(WRITE_COMMANDS.SIGN_UP_USER, params, {optimisticData, successData, failureData}); } -function signInAfterTransitionFromOldDot(route: Route, hybridAppSettings: HybridAppSettings) { - const {initialOnyxValues} = hybridAppSettings; +function signInAfterTransitionFromOldDot(route: Route, hybridAppSettings: string) { + const parsedHybridAppSettings = parseHybridAppSettings(hybridAppSettings); + const {initialOnyxValues} = parsedHybridAppSettings; const {hybridApp} = initialOnyxValues; const clearOnyxBeforeSignIn = () => {