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
9 changes: 1 addition & 8 deletions __mocks__/@ua/react-native-airship.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,6 @@ enum EventType {
PushReceived = 'com.airship.push_received',
}

// eslint-disable-next-line no-restricted-syntax
enum PermissionStatus {
Granted = 'granted',
Denied = 'denied',
NotDetermined = 'not_determined',
}

// eslint-disable-next-line @typescript-eslint/no-namespace
namespace iOS {
/**
Expand Down Expand Up @@ -78,4 +71,4 @@ const Airship: Partial<AirshipRoot> = {

export default Airship;

export {EventType, iOS, PermissionStatus};
export {EventType, iOS};
Original file line number Diff line number Diff line change
Expand Up @@ -51,22 +51,4 @@ class ReactNativeHybridApp(reactContext: ReactApplicationContext) :
override fun onURLListenerAdded() {
Log.d(NAME, "`onURLListenerAdded` should never be called in standalone `New Expensify` app")
}

override fun signInToOldDot(
autoGeneratedLogin: String,
autoGeneratedPassword: String,
authToken: String,
email: String,
policyID: String
) {
Log.d(NAME, "`signInToOldDot` should never be called in standalone `New Expensify` app")
}

override fun signOutFromOldDot() {
Log.d(NAME, "`signOutFromOldDot` should never be called in standalone `New Expensify` app")
}

override fun clearOldDotAfterSignOut() {
Log.d(NAME, "`clearOldDotAfterSignOut` should never be called in standalone `New Expensify` app")
}
}
12 changes: 0 additions & 12 deletions modules/hybrid-app/ios/ReactNativeHybridApp.mm
Original file line number Diff line number Diff line change
Expand Up @@ -43,18 +43,6 @@ - (void)onURLListenerAdded {
NSLog(@"[ReactNativeHybridApp] `onURLListenerAdded` should never be called in standalone `New Expensify` app");
}

- (void)signInToOldDot:(NSString *)autoGeneratedLogin autoGeneratedPassword:(NSString *)autoGeneratedPassword authToken:(NSString *)authToken email:(NSString *)email policyID:(NSString *)policyID {
NSLog(@"[ReactNativeHybridApp] `signInToOldDot` should never be called in standalone `New Expensify` app");
}

- (void)signOutFromOldDot {
NSLog(@"[ReactNativeHybridApp] `signOutFromOldDot` should never be called in standalone `New Expensify` app");
}

- (void)clearOldDotAfterSignOut {
NSLog(@"[ReactNativeHybridApp] `clearOldDotAfterSignOut` should never be called in standalone `New Expensify` app");
}

- (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:
(const facebook::react::ObjCTurboModule::InitParams &)params
{
Expand Down
3 changes: 0 additions & 3 deletions modules/hybrid-app/src/NativeReactNativeHybridApp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@ export interface Spec extends TurboModule {
getHybridAppSettings: () => Promise<string | null>;
getInitialURL(): Promise<string | null>;
onURLListenerAdded: () => void;
signInToOldDot: (autoGeneratedLogin: string, autoGeneratedPassword: string, authToken: string, email: string, policyID: string) => void;
signOutFromOldDot: () => void;
clearOldDotAfterSignOut: () => void;
}

export default TurboModuleRegistry.getEnforcing<Spec>('ReactNativeHybridApp');
9 changes: 0 additions & 9 deletions modules/hybrid-app/src/index.native.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,6 @@ const HybridAppModule: HybridAppModuleType = {
onURLListenerAdded() {
ReactNativeHybridApp.onURLListenerAdded();
},
signInToOldDot({autoGeneratedLogin, autoGeneratedPassword, authToken, email, policyID}) {
ReactNativeHybridApp.signInToOldDot(autoGeneratedLogin, autoGeneratedPassword, authToken, email, policyID);
},
signOutFromOldDot() {
ReactNativeHybridApp.signOutFromOldDot();
},
clearOldDotAfterSignOut() {
ReactNativeHybridApp.clearOldDotAfterSignOut();
},
};

export default HybridAppModule;
12 changes: 0 additions & 12 deletions modules/hybrid-app/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,18 +38,6 @@ const HybridAppModule: HybridAppModuleType = {
// eslint-disable-next-line no-console
console.warn('HybridAppModule: `onURLListenerAdded` should never be called on web');
},
signInToOldDot() {
// eslint-disable-next-line no-console
console.warn('HybridAppModule: `signInToOldDot` should never be called on web');
},
signOutFromOldDot() {
// eslint-disable-next-line no-console
console.warn('HybridAppModule: `signOutFromOldDot` should never be called on web');
},
clearOldDotAfterSignOut() {
// eslint-disable-next-line no-console
console.warn('HybridAppModule: `clearOldDotAfterSignOut` should never be called on web');
},
};

export default HybridAppModule;
3 changes: 0 additions & 3 deletions modules/hybrid-app/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@ type HybridAppModuleType = {
getHybridAppSettings: () => Promise<string | null>;
getInitialURL(): Promise<string | null>;
onURLListenerAdded: () => void;
signInToOldDot: (args: {autoGeneratedLogin: string; autoGeneratedPassword: string; authToken: string; email: string; policyID: string}) => void;
signOutFromOldDot: () => void;
clearOldDotAfterSignOut: () => void;
};

export default HybridAppModuleType;
91 changes: 40 additions & 51 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ import {CurrentReportIDContextProvider} from './hooks/useCurrentReportID';
import useDefaultDragAndDrop from './hooks/useDefaultDragAndDrop';
import HybridAppHandler from './HybridAppHandler';
import OnyxUpdateManager from './libs/actions/OnyxUpdateManager';
import './libs/HybridApp';
import {AttachmentModalContextProvider} from './pages/media/AttachmentModalScreen/AttachmentModalContext';
import './setup/backgroundTask';
import './setup/hybridApp';
Expand Down Expand Up @@ -70,57 +69,47 @@ function App() {
<InitialURLContextProvider>
<HybridAppHandler />
<GestureHandlerRootView style={fill}>
{/* Initialize metrics early to ensure the UI renders even when NewDot is hidden.
This is necessary for iOS HybridApp's SignInPage to appear correctly without the bootsplash.
See: https://github.com/Expensify/App/pull/65178#issuecomment-3139026551
*/}
<SafeAreaProvider
initialMetrics={{
insets: {top: 0, right: 0, bottom: 0, left: 0},
frame: {x: 0, y: 0, width: 0, height: 0},
}}
<ComposeProviders
components={[
OnyxListItemProvider,
ThemeProvider,
ThemeStylesProvider,
ThemeIllustrationsProvider,
SafeAreaProvider,
HTMLEngineProvider,
PortalProvider,
SafeArea,
LocaleContextProvider,
PopoverContextProvider,
CurrentReportIDContextProvider,
ScrollOffsetContextProvider,
AttachmentModalContextProvider,
PickerStateProvider,
EnvironmentProvider,
CustomStatusBarAndBackgroundContextProvider,
ActiveElementRoleProvider,
ActionSheetAwareScrollViewProvider,
PlaybackContextProvider,
FullScreenContextProvider,
VolumeContextProvider,
VideoPopoverMenuContextProvider,
KeyboardProvider,
KeyboardStateProvider,
SearchRouterContextProvider,
ProductTrainingContextProvider,
InputBlurContextProvider,
FullScreenBlockingViewContextProvider,
FullScreenLoaderContextProvider,
]}
>
<ComposeProviders
components={[
OnyxListItemProvider,
ThemeProvider,
ThemeStylesProvider,
ThemeIllustrationsProvider,
HTMLEngineProvider,
PortalProvider,
SafeArea,
LocaleContextProvider,
PopoverContextProvider,
CurrentReportIDContextProvider,
ScrollOffsetContextProvider,
AttachmentModalContextProvider,
PickerStateProvider,
EnvironmentProvider,
CustomStatusBarAndBackgroundContextProvider,
ActiveElementRoleProvider,
ActionSheetAwareScrollViewProvider,
PlaybackContextProvider,
FullScreenContextProvider,
VolumeContextProvider,
VideoPopoverMenuContextProvider,
KeyboardProvider,
KeyboardStateProvider,
SearchRouterContextProvider,
ProductTrainingContextProvider,
InputBlurContextProvider,
FullScreenBlockingViewContextProvider,
FullScreenLoaderContextProvider,
]}
>
<CustomStatusBarAndBackground />
<ErrorBoundary errorMessage="NewExpensify crash caught by error boundary">
<ColorSchemeWrapper>
<Expensify />
</ColorSchemeWrapper>
</ErrorBoundary>
<NavigationBar />
</ComposeProviders>
</SafeAreaProvider>
<CustomStatusBarAndBackground />
<ErrorBoundary errorMessage="NewExpensify crash caught by error boundary">
<ColorSchemeWrapper>
<Expensify />
</ColorSchemeWrapper>
</ErrorBoundary>
<NavigationBar />
</ComposeProviders>
</GestureHandlerRootView>
</InitialURLContextProvider>
</SplashScreenStateContextProvider>
Expand Down
11 changes: 0 additions & 11 deletions src/CONFIG.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,18 +95,7 @@ export default {
GOOGLE_SIGN_IN: {
// cspell:disable-next-line
WEB_CLIENT_ID: '921154746561-gpsoaqgqfuqrfsjdf8l7vohfkfj7b9up.apps.googleusercontent.com',
// cspell:disable-next-line
IOS_CLIENT_ID: '921154746561-s3uqn2oe4m85tufi6mqflbfbuajrm2i3.apps.googleusercontent.com',
HYBRID_APP: {
// cspell:disable-next-line
IOS_CLIENT_ID: '1008697809946-sh04nqq0hea396s1qdqqbj6ia649odb2.apps.googleusercontent.com',
WEB_CLIENT_ID: {
// cspell:disable-next-line
IOS: '1008697809946-5e095eqem3o6ugtpc2rjf7v880tcp28p.apps.googleusercontent.com',
// cspell:disable-next-line
ANDROID: '240677659774-86pov3adub93cv4b8uj13g7varolmk2l.apps.googleusercontent.com',
},
},
},
GCP_GEOLOCATION_API_KEY: googleGeolocationAPIKey,
FIREBASE_WEB_CONFIG: {
Expand Down
19 changes: 3 additions & 16 deletions src/Expensify.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ function Expensify() {
const [currentOnboardingPurposeSelected] = useOnyx(ONYXKEYS.ONBOARDING_PURPOSE_SELECTED, {canBeMissing: true});
const [currentOnboardingCompanySize] = useOnyx(ONYXKEYS.ONBOARDING_COMPANY_SIZE, {canBeMissing: true});
const [onboardingInitialPath] = useOnyx(ONYXKEYS.ONBOARDING_LAST_VISITED_PATH, {canBeMissing: true});
const [hybridApp] = useOnyx(ONYXKEYS.HYBRID_APP, {canBeMissing: true});

useDebugShortcut();
usePriorityMode();
Expand All @@ -122,22 +121,10 @@ function Expensify() {
const isAuthenticated = useIsAuthenticated();
const autoAuthState = useMemo(() => session?.autoAuthState ?? '', [session]);

const isSplashReadyToBeHidden = splashScreenState === CONST.BOOT_SPLASH_STATE.READY_TO_BE_HIDDEN;
const isSplashVisible = splashScreenState === CONST.BOOT_SPLASH_STATE.VISIBLE;

const shouldInit = isNavigationReady && hasAttemptedToOpenPublicRoom && !!preferredLocale;
const shouldHideSplash = (isSplashReadyToBeHidden || isSplashVisible) && shouldInit && !hybridApp?.loggedOutFromOldDot;

// This effect is closing OldDot sign out modal based on splash screen state
useEffect(() => {
if (!isSplashReadyToBeHidden || !isNavigationReady || !hasAttemptedToOpenPublicRoom || !hybridApp?.loggedOutFromOldDot) {
return;
}

setSplashScreenState(CONST.BOOT_SPLASH_STATE.HIDDEN);
HybridAppModule.clearOldDotAfterSignOut();
}, [hasAttemptedToOpenPublicRoom, hybridApp?.loggedOutFromOldDot, isNavigationReady, isSplashReadyToBeHidden, setSplashScreenState]);

const isSplashVisible = splashScreenState === CONST.BOOT_SPLASH_STATE.VISIBLE;
const isHybridAppReady = splashScreenState === CONST.BOOT_SPLASH_STATE.READY_TO_BE_HIDDEN && isAuthenticated;
const shouldHideSplash = shouldInit && (CONFIG.IS_HYBRID_APP ? isHybridAppReady : isSplashVisible);
const initializeClient = () => {
if (!Visibility.isVisible()) {
return;
Expand Down
20 changes: 5 additions & 15 deletions src/HybridAppHandler.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,15 @@ import HybridAppModule from '@expensify/react-native-hybrid-app';
import {useContext, useEffect} from 'react';
import CONFIG from './CONFIG';
import CONST from './CONST';
import useOnyx from './hooks/useOnyx';
import {parseHybridAppSettings} from './libs/actions/HybridApp';
import {setupNewDotAfterTransitionFromOldDot} from './libs/actions/Session';
import {signInAfterTransitionFromOldDot} from './libs/actions/Session';
import Log from './libs/Log';
import ONYXKEYS from './ONYXKEYS';
import SplashScreenStateContext from './SplashScreenStateContext';
import isLoadingOnyxValue from './types/utils/isLoadingOnyxValue';

function HybridAppHandler() {
const {splashScreenState, setSplashScreenState} = useContext(SplashScreenStateContext);
const [tryNewDot, tryNewDotMetadata] = useOnyx(ONYXKEYS.NVP_TRY_NEW_DOT, {canBeMissing: true});

const isLoading = isLoadingOnyxValue(tryNewDotMetadata);
const {setSplashScreenState} = useContext(SplashScreenStateContext);

useEffect(() => {
if (!CONFIG.IS_HYBRID_APP || isLoading) {
if (!CONFIG.IS_HYBRID_APP) {
return;
}

Expand All @@ -28,14 +21,11 @@ function HybridAppHandler() {
return;
}

setupNewDotAfterTransitionFromOldDot(parseHybridAppSettings(hybridAppSettings), tryNewDot).then(() => {
if (splashScreenState !== CONST.BOOT_SPLASH_STATE.VISIBLE) {
return;
}
signInAfterTransitionFromOldDot(hybridAppSettings).then(() => {
setSplashScreenState(CONST.BOOT_SPLASH_STATE.READY_TO_BE_HIDDEN);
});
});
}, [isLoading, setSplashScreenState, splashScreenState, tryNewDot]);
}, [setSplashScreenState]);

return null;
}
Expand Down
2 changes: 1 addition & 1 deletion src/components/ScreenWrapper/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import NarrowPaneContext from '@libs/Navigation/AppNavigator/Navigators/NarrowPa
import Navigation from '@libs/Navigation/Navigation';
import type {PlatformStackNavigationProp} from '@libs/Navigation/PlatformStackNavigation/types';
import type {ReportsSplitNavigatorParamList, RootNavigatorParamList} from '@libs/Navigation/types';
import {closeReactNativeApp} from '@userActions/HybridApp';
import closeReactNativeApp from '@userActions/HybridApp';
import CONFIG from '@src/CONFIG';
import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
Expand Down
20 changes: 4 additions & 16 deletions src/components/SignInButtons/GoogleSignIn/index.native.tsx
Original file line number Diff line number Diff line change
@@ -1,32 +1,20 @@
import {GoogleSignin, statusCodes} from '@react-native-google-signin/google-signin';
import React from 'react';
import IconButton from '@components/SignInButtons/IconButton';
import getPlatform from '@libs/getPlatform';
import Log from '@libs/Log';
import {beginGoogleSignIn} from '@userActions/Session';
import * as Session from '@userActions/Session';

Check failure on line 5 in src/components/SignInButtons/GoogleSignIn/index.native.tsx

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Namespace imports from @userActions are not allowed. Use named imports instead. Example: import { action } from "@userActions/module"
import CONFIG from '@src/CONFIG';
import CONST from '@src/CONST';
import type {GoogleSignInProps} from '.';
import type GoogleError from './types';

/**
* Helper function returning webClientId based on a platform used
*/
function getWebClientId() {
if (!CONFIG.IS_HYBRID_APP) {
return CONFIG.GOOGLE_SIGN_IN.WEB_CLIENT_ID;
}

return getPlatform() === CONST.PLATFORM.ANDROID ? CONFIG.GOOGLE_SIGN_IN.HYBRID_APP.WEB_CLIENT_ID.ANDROID : CONFIG.GOOGLE_SIGN_IN.HYBRID_APP.WEB_CLIENT_ID.IOS;
}

/**
* Google Sign In method for iOS and android that returns identityToken.
*/
function googleSignInRequest() {
GoogleSignin.configure({
webClientId: getWebClientId(),
iosClientId: CONFIG.IS_HYBRID_APP ? CONFIG.GOOGLE_SIGN_IN.HYBRID_APP.IOS_CLIENT_ID : CONFIG.GOOGLE_SIGN_IN.IOS_CLIENT_ID,
webClientId: CONFIG.GOOGLE_SIGN_IN.WEB_CLIENT_ID,
iosClientId: CONFIG.GOOGLE_SIGN_IN.IOS_CLIENT_ID,
offlineAccess: false,
});

Expand All @@ -37,7 +25,7 @@

GoogleSignin.signIn()
.then((response) => response.idToken)
.then((token) => beginGoogleSignIn(token))
.then((token) => Session.beginGoogleSignIn(token))
.catch((error: GoogleError | undefined) => {
// Handle unexpected error shape
if (error?.code === undefined) {
Expand Down
Loading
Loading