Skip to content

Commit

Permalink
Unify how we pass data on both platforms
Browse files Browse the repository at this point in the history
  • Loading branch information
mateuuszzzzz committed Nov 6, 2024
1 parent a2266c8 commit dc6651e
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 8 deletions.
3 changes: 1 addition & 2 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,14 @@ 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';
import {SplashScreenStateContextProvider} from './SplashScreenStateContext';

type AppProps = {
url?: Route;
hybridAppSettings?: HybridAppSettings;
hybridAppSettings?: string;
};

LogBox.ignoreLogs([
Expand Down
3 changes: 1 addition & 2 deletions src/components/InitialURLContextProvider.tsx
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -21,7 +20,7 @@ const InitialURLContext = createContext<InitialUrlContextType>({
type InitialURLContextProviderProps = {
url?: Route;

hybridAppSettings?: HybridAppSettings;
hybridAppSettings?: string;

/** Children passed to the context provider */
children: ReactNode;
Expand Down
6 changes: 5 additions & 1 deletion src/libs/actions/HybridApp/index.ts
Original file line number Diff line number Diff line change
@@ -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;
7 changes: 4 additions & 3 deletions src/libs/actions/Session/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 = () => {
Expand Down

0 comments on commit dc6651e

Please sign in to comment.