Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[HybridApp] Implement POC of NewDot SignIn on HybridApp #51257

Draft
wants to merge 55 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
5eaa292
Implement POC of NewDot login page on HybridApp
mateuuszzzzz Oct 22, 2024
404047f
Merge branch 'main' into make-new-dot-signin-default-for-hybridapp
war-in Oct 28, 2024
f81ec86
fix android crash
war-in Oct 29, 2024
290748d
add HybridApp onyx key
war-in Oct 29, 2024
05c4573
wip - sending native events
war-in Oct 31, 2024
b6e14aa
Merge branch 'refs/heads/main' into war-in/unmock-signing-in
war-in Oct 31, 2024
bb05ef9
js logic
war-in Oct 31, 2024
94ebb8f
fix switching to new experience
war-in Oct 31, 2024
a9ff586
block switching when still signing in to OD
war-in Oct 31, 2024
ec6315e
reset onyx values on start
war-in Oct 31, 2024
db0d806
Merge branch 'refs/heads/main' into make-new-dot-signin-default-for-h…
war-in Oct 31, 2024
e1562bb
preserve HYBRID_APP onyx key when signing out
war-in Oct 31, 2024
efde805
fix
war-in Oct 31, 2024
a1b9e1a
move part of resetting logic
war-in Oct 31, 2024
3ad1b62
move useNewDotSignInPage to HybridApp key
war-in Nov 4, 2024
f9b0e5a
fix lint & typecheck
war-in Nov 4, 2024
377b686
correctly set onyx props when switching from OD
war-in Nov 4, 2024
90f7c0f
don't set HybridApp key in onyx (merge it)
war-in Nov 4, 2024
4b3e539
send error message on failed OD login
war-in Nov 4, 2024
026ac7b
add useOldDot const
war-in Nov 5, 2024
624be42
Merge branch 'main' into war-in/unmock-signing-in
war-in Nov 6, 2024
44dffc8
Merge branch 'war-in/unmock-signing-in' into make-new-dot-signin-defa…
war-in Nov 6, 2024
d976148
Bootsplash logic in hybridapp (#132)
jnowakow Nov 7, 2024
11e444d
Merge branch 'main' into make-new-dot-signin-default-for-hybridapp
war-in Nov 12, 2024
a78141d
fix clearing onyx
war-in Nov 13, 2024
deaba6f
[HybridApp] Do not use query params in AppProp URL (#125)
mateuuszzzzz Nov 13, 2024
f2e3bb4
Handle OD sing-in errors (#136)
war-in Nov 13, 2024
8859b6c
add disabled to button
war-in Nov 13, 2024
a3436bc
move sign in state to HybridApp key
war-in Nov 13, 2024
703c31d
add loading indicator and error modal
war-in Nov 14, 2024
1f6a0e1
move sign in logic to HybridApp.ts
war-in Nov 14, 2024
63a3de8
fix lint
war-in Nov 14, 2024
9fdeebb
Merge branch 'main' into make-new-dot-signin-default-for-hybridapp
mateuuszzzzz Nov 18, 2024
4bc9f90
Merge branch 'main' into make-new-dot-signin-default-for-hybridapp
mateuuszzzzz Nov 20, 2024
1a99fd1
Prevent closing NewDot on first transition with button
mateuuszzzzz Nov 20, 2024
0e601bd
use "tryNewDot" value to determine which app should be opened
war-in Nov 21, 2024
1c0c219
first step to fix deeplinks
war-in Nov 21, 2024
c848cfd
Merge branch 'main' into make-new-dot-signin-default-for-hybridapp
war-in Nov 27, 2024
4170968
improve openApp flow
war-in Nov 27, 2024
50c3fed
[HybridApp] Clean code (#143)
mateuuszzzzz Nov 27, 2024
fb82b65
[HybridApp] Refactor `SignInPage` PR v2 (#144)
mateuuszzzzz Nov 28, 2024
ecb93e2
fix part of signup flow
war-in Nov 27, 2024
6f926fe
[SignIn Page] New user flow (#145)
war-in Nov 28, 2024
f540207
Merge branch 'main' into make-new-dot-signin-default-for-hybridapp
war-in Nov 28, 2024
5aae4be
Merge remote-tracking branch 'origin/make-new-dot-signin-default-for-…
war-in Nov 28, 2024
90c0954
fix isSingleNewDotEntry logic (travel feature)
war-in Dec 2, 2024
13180c2
Merge branch 'main' into make-new-dot-signin-default-for-hybridapp
war-in Dec 2, 2024
ddb9aef
Merge branch 'main' into make-new-dot-signin-default-for-hybridapp
war-in Dec 5, 2024
9cfbaf5
Rename argument
mateuuszzzzz Dec 5, 2024
85eddb2
Change function name
mateuuszzzzz Dec 5, 2024
bddba03
Merge branch 'main' into make-new-dot-signin-default-for-hybridapp
war-in Dec 9, 2024
68ed516
Dont sign in in old dot (#150)
war-in Dec 9, 2024
9450d21
clear onyx but leave same data as when signing out
war-in Dec 9, 2024
62b861c
Improve data fetching on OldDot side
mateuuszzzzz Dec 10, 2024
8ea545c
Merge branch 'main' into make-new-dot-signin-default-for-hybridapp
mateuuszzzzz Dec 11, 2024
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
12 changes: 9 additions & 3 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,12 @@ import {ReportAttachmentsProvider} from './pages/home/report/ReportAttachmentsCo
import type {Route} from './ROUTES';
import {SplashScreenStateContextProvider} from './SplashScreenStateContext';

/**
* URL and settings passed to our top-level React Native component by HybridApp. Will always be undefined in "pure" NewDot builds.
*/
type AppProps = {
/** URL passed to our top-level React Native component by HybridApp. Will always be undefined in "pure" NewDot builds. */
url?: Route;
hybridAppSettings?: string;
};

LogBox.ignoreLogs([
Expand All @@ -58,14 +61,17 @@ const fill = {flex: 1};

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

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

return (
<StrictModeWrapper>
<SplashScreenStateContextProvider>
<InitialURLContextProvider url={url}>
<InitialURLContextProvider
url={url}
hybridAppSettings={hybridAppSettings}
>
<GestureHandlerRootView style={fill}>
<ComposeProviders
components={[
Expand Down
9 changes: 9 additions & 0 deletions src/CONST.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4645,6 +4645,9 @@ const CONST = {
},
EVENTS: {
SCROLLING: 'scrolling',
HYBRID_APP: {
ON_SIGN_IN_FINISHED: 'onSignInFinished',
},
},

CHAT_HEADER_LOADER_HEIGHT: 36,
Expand Down Expand Up @@ -6302,6 +6305,12 @@ const CONST = {
HIDDEN: `hidden`,
},

HYBRID_APP_SIGN_IN_STATE: {
NOT_STARTED: 'notStarted',
STARTED: 'started',
FINISHED: 'finished',
},

CSV_IMPORT_COLUMNS: {
EMAIL: 'email',
NAME: 'name',
Expand Down
9 changes: 7 additions & 2 deletions src/Expensify.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ function Expensify() {
const [screenShareRequest] = useOnyx(ONYXKEYS.SCREEN_SHARE_REQUEST);
const [focusModeNotification] = useOnyx(ONYXKEYS.FOCUS_MODE_NOTIFICATION, {initWithStoredValues: false});
const [lastVisitedPath] = useOnyx(ONYXKEYS.LAST_VISITED_PATH);
const [hybridApp] = useOnyx(ONYXKEYS.HYBRID_APP);

useEffect(() => {
if (!account?.needsTwoFactorAuthSetup || account.requiresTwoFactorAuth) {
Expand All @@ -115,10 +116,14 @@ function Expensify() {
const isAuthenticated = useMemo(() => !!(session?.authToken ?? null), [session]);
const autoAuthState = useMemo(() => session?.autoAuthState ?? '', [session]);

const shouldInit = isNavigationReady && hasAttemptedToOpenPublicRoom;
const shouldInit = NativeModules.HybridAppModule
? !hybridApp?.loggedOutFromOldDot && isNavigationReady && hasAttemptedToOpenPublicRoom
: isNavigationReady && hasAttemptedToOpenPublicRoom;
const shouldHideSplash =
shouldInit &&
(NativeModules.HybridAppModule ? splashScreenState === CONST.BOOT_SPLASH_STATE.READY_TO_BE_HIDDEN && isAuthenticated : splashScreenState === CONST.BOOT_SPLASH_STATE.VISIBLE);
(NativeModules.HybridAppModule
? splashScreenState === CONST.BOOT_SPLASH_STATE.READY_TO_BE_HIDDEN && (isAuthenticated || !!hybridApp?.useNewDotSignInPage)
: splashScreenState === CONST.BOOT_SPLASH_STATE.VISIBLE);

const initializeClient = () => {
if (!Visibility.isVisible()) {
Expand Down
7 changes: 3 additions & 4 deletions src/ONYXKEYS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -455,15 +455,14 @@ const ONYXKEYS = {
/** Stores recently used currencies */
RECENTLY_USED_CURRENCIES: 'nvp_recentlyUsedCurrencies',

/** States whether we transitioned from OldDot to show only certain group of screens. It should be undefined on pure NewDot. */
IS_SINGLE_NEW_DOT_ENTRY: 'isSingleNewDotEntry',

/** Company cards custom names */
NVP_EXPENSIFY_COMPANY_CARDS_CUSTOM_NAMES: 'nvp_expensify_ccCustomNames',

/** The user's Concierge reportID */
CONCIERGE_REPORT_ID: 'conciergeReportID',

HYBRID_APP: 'hybridApp',

/** Collection Keys */
COLLECTION: {
DOWNLOAD: 'download_',
Expand Down Expand Up @@ -1025,12 +1024,12 @@ type OnyxValuesMapping = {
[ONYXKEYS.APPROVAL_WORKFLOW]: OnyxTypes.ApprovalWorkflowOnyx;
[ONYXKEYS.IMPORTED_SPREADSHEET]: OnyxTypes.ImportedSpreadsheet;
[ONYXKEYS.LAST_ROUTE]: string;
[ONYXKEYS.IS_SINGLE_NEW_DOT_ENTRY]: boolean | undefined;
[ONYXKEYS.IS_USING_IMPORTED_STATE]: boolean;
[ONYXKEYS.SHOULD_SHOW_SAVED_SEARCH_RENAME_TOOLTIP]: boolean;
[ONYXKEYS.NVP_EXPENSIFY_COMPANY_CARDS_CUSTOM_NAMES]: Record<string, string>;
[ONYXKEYS.CONCIERGE_REPORT_ID]: string;
[ONYXKEYS.NVP_DISMISSED_PRODUCT_TRAINING]: OnyxTypes.DismissedProductTraining;
[ONYXKEYS.HYBRID_APP]: OnyxTypes.HybridApp;
};
type OnyxValues = OnyxValuesMapping & OnyxCollectionValuesMapping & OnyxFormValuesMapping & OnyxFormDraftValuesMapping;

Expand Down
33 changes: 21 additions & 12 deletions src/components/InitialURLContextProvider.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import React, {createContext, useEffect, useMemo, useState} from 'react';
import React, {createContext, useEffect, useMemo, useRef, useState} from 'react';
import type {ReactNode} from 'react';
import {Linking} from 'react-native';
import {useOnyx} from 'react-native-onyx';
import type {ValueOf} from 'type-fest';
import {signInAfterTransitionFromOldDot} from '@libs/actions/Session';
import {setupNewDotAfterTransitionFromOldDot} from '@libs/actions/Session';
import Navigation from '@navigation/Navigation';
import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import type {Route} from '@src/ROUTES';
import {useSplashScreenStateContext} from '@src/SplashScreenStateContext';
import isLoadingOnyxValue from '@src/types/utils/isLoadingOnyxValue';

type InitialUrlContextType = {
initialURL: Route | undefined;
Expand All @@ -25,14 +26,19 @@ type InitialURLContextProviderProps = {
/** URL passed to our top-level React Native component by HybridApp. Will always be undefined in "pure" NewDot builds. */
url?: Route | ValueOf<typeof CONST.HYBRID_APP>;

hybridAppSettings?: string;

/** Children passed to the context provider */
children: ReactNode;
};

function InitialURLContextProvider({children, url}: InitialURLContextProviderProps) {
const [initialURL, setInitialURL] = useState<Route | undefined>();
function InitialURLContextProvider({children, url, hybridAppSettings}: InitialURLContextProviderProps) {
const [initialURL, setInitialURL] = useState<Route | ValueOf<typeof CONST.HYBRID_APP> | undefined>(url);
const [lastVisitedPath] = useOnyx(ONYXKEYS.LAST_VISITED_PATH);
const {splashScreenState, setSplashScreenState} = useSplashScreenStateContext();
const [tryNewDot, tryNewDotMetadata] = useOnyx(ONYXKEYS.NVP_TRYNEWDOT);
// We use `setupCalled` ref to guarantee that `signInAfterTransitionFromOldDot` is called once.
const setupCalled = useRef(false);

useEffect(() => {
if (url !== CONST.HYBRID_APP.REORDERING_REACT_NATIVE_ACTIVITY_TO_FRONT) {
Expand All @@ -50,22 +56,25 @@ function InitialURLContextProvider({children, url}: InitialURLContextProviderPro
return;
}

if (url) {
signInAfterTransitionFromOldDot(url).then((route) => {
setInitialURL(route);
setSplashScreenState(CONST.BOOT_SPLASH_STATE.READY_TO_BE_HIDDEN);
});
if (url && hybridAppSettings) {
if (!isLoadingOnyxValue(tryNewDotMetadata) && !setupCalled.current) {
setupCalled.current = true;
setupNewDotAfterTransitionFromOldDot(url, hybridAppSettings, tryNewDot).then((route) => {
setInitialURL(route);
setSplashScreenState(CONST.BOOT_SPLASH_STATE.READY_TO_BE_HIDDEN);
});
}
return;
}
Linking.getInitialURL().then((initURL) => {
setInitialURL(initURL as Route);
});
}, [setSplashScreenState, url]);
}, [hybridAppSettings, setSplashScreenState, tryNewDot, tryNewDotMetadata, url]);

const initialUrlContext = useMemo(
() => ({
initialURL,
setInitialURL,
initialURL: initialURL === CONST.HYBRID_APP.REORDERING_REACT_NATIVE_ACTIVITY_TO_FRONT ? undefined : initialURL,
setInitialURL: setInitialURL as React.Dispatch<React.SetStateAction<Route | undefined>>,
}),
[initialURL],
);
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/useOnboardingFlow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ function useOnboardingFlowRouter() {

const [dismissedProductTraining, dismissedProductTrainingMetadata] = useOnyx(ONYXKEYS.NVP_DISMISSED_PRODUCT_TRAINING);

const [isSingleNewDotEntry, isSingleNewDotEntryMetadata] = useOnyx(ONYXKEYS.IS_SINGLE_NEW_DOT_ENTRY);
const [isSingleNewDotEntry, isSingleNewDotEntryMetadata] = useOnyx(ONYXKEYS.HYBRID_APP, {selector: (data) => data?.isSingleNewDotEntry});
const [allBetas, allBetasMetadata] = useOnyx(ONYXKEYS.BETAS);
useEffect(() => {
if (isLoadingOnyxValue(isOnboardingCompletedMetadata, tryNewDotdMetadata, dismissedProductTrainingMetadata, allBetasMetadata)) {
Expand Down
8 changes: 4 additions & 4 deletions src/libs/API/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ const WRITE_COMMANDS = {
REQUEST_NEW_VALIDATE_CODE: 'RequestNewValidateCode',
SIGN_IN_WITH_APPLE: 'SignInWithApple',
SIGN_IN_WITH_GOOGLE: 'SignInWithGoogle',
SIGN_IN_USER: 'SigninUser',
SIGN_IN_USER_WITH_LINK: 'SigninUserWithLink',
SEARCH: 'Search',
REQUEST_UNLINK_VALIDATION_LINK: 'RequestUnlinkValidationLink',
Expand Down Expand Up @@ -307,7 +306,6 @@ const WRITE_COMMANDS = {
TRANSACTION_MERGE: 'Transaction_Merge',
RESOLVE_DUPLICATES: 'ResolveDuplicates',
UPDATE_SUBSCRIPTION_TYPE: 'UpdateSubscriptionType',
SIGN_UP_USER: 'SignUpUser',
UPDATE_SUBSCRIPTION_AUTO_RENEW: 'UpdateSubscriptionAutoRenew',
UPDATE_SUBSCRIPTION_ADD_NEW_USERS_AUTOMATICALLY: 'UpdateSubscriptionAddNewUsersAutomatically',
UPDATE_SUBSCRIPTION_SIZE: 'UpdateSubscriptionSize',
Expand Down Expand Up @@ -517,7 +515,6 @@ type WriteCommandParameters = {
[WRITE_COMMANDS.REQUEST_NEW_VALIDATE_CODE]: Parameters.RequestNewValidateCodeParams;
[WRITE_COMMANDS.SIGN_IN_WITH_APPLE]: Parameters.BeginAppleSignInParams;
[WRITE_COMMANDS.SIGN_IN_WITH_GOOGLE]: Parameters.BeginGoogleSignInParams;
[WRITE_COMMANDS.SIGN_IN_USER]: SignInUserParams;
[WRITE_COMMANDS.SIGN_IN_USER_WITH_LINK]: Parameters.SignInUserWithLinkParams;
[WRITE_COMMANDS.REQUEST_UNLINK_VALIDATION_LINK]: Parameters.RequestUnlinkValidationLinkParams;
[WRITE_COMMANDS.UNLINK_LOGIN]: Parameters.UnlinkLoginParams;
Expand Down Expand Up @@ -758,7 +755,6 @@ type WriteCommandParameters = {
[WRITE_COMMANDS.TRANSACTION_MERGE]: Parameters.TransactionMergeParams;
[WRITE_COMMANDS.RESOLVE_DUPLICATES]: Parameters.ResolveDuplicatesParams;
[WRITE_COMMANDS.UPDATE_SUBSCRIPTION_TYPE]: Parameters.UpdateSubscriptionTypeParams;
[WRITE_COMMANDS.SIGN_UP_USER]: Parameters.SignUpUserParams;
[WRITE_COMMANDS.UPDATE_SUBSCRIPTION_AUTO_RENEW]: Parameters.UpdateSubscriptionAutoRenewParams;
[WRITE_COMMANDS.UPDATE_SUBSCRIPTION_ADD_NEW_USERS_AUTOMATICALLY]: Parameters.UpdateSubscriptionAddNewUsersAutomaticallyParams;
[WRITE_COMMANDS.UPDATE_SUBSCRIPTION_SIZE]: Parameters.UpdateSubscriptionSizeParams;
Expand Down Expand Up @@ -1033,6 +1029,8 @@ const SIDE_EFFECT_REQUEST_COMMANDS = {
DISCONNECT_AS_DELEGATE: 'DisconnectAsDelegate',
COMPLETE_HYBRID_APP_ONBOARDING: 'CompleteHybridAppOnboarding',
CONNECT_POLICY_TO_QUICKBOOKS_DESKTOP: 'ConnectPolicyToQuickbooksDesktop',
SIGN_IN_USER: 'SigninUser',
SIGN_UP_USER: 'SignUpUser',

// PayMoneyRequestOnSearch only works online (pattern C) and we need to play the success sound only when the request is successful
PAY_MONEY_REQUEST_ON_SEARCH: 'PayMoneyRequestOnSearch',
Expand All @@ -1056,6 +1054,8 @@ type SideEffectRequestCommandParameters = {
[SIDE_EFFECT_REQUEST_COMMANDS.DISCONNECT_AS_DELEGATE]: EmptyObject;
[SIDE_EFFECT_REQUEST_COMMANDS.COMPLETE_HYBRID_APP_ONBOARDING]: EmptyObject;
[SIDE_EFFECT_REQUEST_COMMANDS.CONNECT_POLICY_TO_QUICKBOOKS_DESKTOP]: Parameters.ConnectPolicyToQuickBooksDesktopParams;
[SIDE_EFFECT_REQUEST_COMMANDS.SIGN_IN_USER]: SignInUserParams;
[SIDE_EFFECT_REQUEST_COMMANDS.SIGN_UP_USER]: Parameters.SignUpUserParams;
[SIDE_EFFECT_REQUEST_COMMANDS.PAY_MONEY_REQUEST_ON_SEARCH]: Parameters.PayMoneyRequestOnSearchParams;
};

Expand Down
94 changes: 94 additions & 0 deletions src/libs/HybridApp.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
import {NativeModules} from 'react-native';
import Onyx from 'react-native-onyx';
import type {OnyxEntry} from 'react-native-onyx';
import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import type {Credentials, HybridApp, Session, TryNewDot} from '@src/types/onyx';
import * as HybridAppActions from './actions/HybridApp';
import Log from './Log';
import {getCurrentUserEmail} from './Network/NetworkStore';

let currentHybridApp: OnyxEntry<HybridApp>;
let currentTryNewDot: OnyxEntry<TryNewDot>;
let currentCredentials: OnyxEntry<Credentials>;

Onyx.connect({
key: ONYXKEYS.HYBRID_APP,
callback: (hybridApp) => {
handleChangeInHybridAppSignInFlow(hybridApp, currentTryNewDot, currentCredentials);
},
});

Onyx.connect({
key: ONYXKEYS.NVP_TRYNEWDOT,
callback: (tryNewDot) => {
handleChangeInHybridAppSignInFlow(currentHybridApp, tryNewDot, currentCredentials);
},
});

Onyx.connect({
key: ONYXKEYS.CREDENTIALS,
callback: (credentials) => {
currentCredentials = credentials;
handleChangeInHybridAppSignInFlow(currentHybridApp, currentTryNewDot, credentials);
},
});

let currentSession: OnyxEntry<Session>;
Onyx.connect({
key: ONYXKEYS.SESSION,
callback: (session: OnyxEntry<Session>) => {
if (!currentSession?.authToken && session?.authToken && currentHybridApp?.newDotSignInState === CONST.HYBRID_APP_SIGN_IN_STATE.STARTED) {
HybridAppActions.setNewDotSignInState(CONST.HYBRID_APP_SIGN_IN_STATE.FINISHED);
}
currentSession = session;
},
});

let activePolicyID: OnyxEntry<string>;
Onyx.connect({
key: ONYXKEYS.NVP_ACTIVE_POLICY_ID,
callback: (newActivePolicyID) => {
activePolicyID = newActivePolicyID;
},
});

function shouldUseOldApp(tryNewDot?: TryNewDot) {
return tryNewDot?.classicRedirect.dismissed === true;
}

function handleChangeInHybridAppSignInFlow(hybridApp: OnyxEntry<HybridApp>, tryNewDot: OnyxEntry<TryNewDot>, credentials: OnyxEntry<Credentials>) {
if (!NativeModules.HybridAppModule) {
return;
}

if (!hybridApp?.useNewDotSignInPage) {
currentHybridApp = hybridApp;
currentTryNewDot = tryNewDot;
return;
}

if (hybridApp?.newDotSignInState === CONST.HYBRID_APP_SIGN_IN_STATE.FINISHED && tryNewDot !== undefined && !!credentials?.autoGeneratedLogin && !!credentials?.autoGeneratedPassword) {
Log.info(`[HybridApp] Performing sign-in${shouldUseOldApp(tryNewDot) ? '' : ' (in background)'} on OldDot side`);
NativeModules.HybridAppModule.signInToOldDot(
credentials.autoGeneratedLogin,
credentials.autoGeneratedPassword,
currentSession?.authToken ?? '',
getCurrentUserEmail() ?? '',
activePolicyID ?? '',
);
HybridAppActions.setUseNewDotSignInPage(false).then(() => {
if (shouldUseOldApp(tryNewDot)) {
NativeModules.HybridAppModule.closeReactNativeApp(false, false);
} else {
Log.info('[HybridApp] The user should see NewDot. There is no need to block the user on the `SignInPage` until the sign-in process is completed on the OldDot side.');
HybridAppActions.setReadyToShowAuthScreens(true);
}
});
}

currentHybridApp = hybridApp;
currentTryNewDot = tryNewDot;
}

export default {shouldUseOldApp};
19 changes: 8 additions & 11 deletions src/libs/Navigation/AppNavigator/AuthScreens.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {findFocusedRoute} from '@react-navigation/native';
import React, {memo, useEffect, useRef, useState} from 'react';
import {NativeModules, View} from 'react-native';
import {View} from 'react-native';
import type {OnyxEntry} from 'react-native-onyx';
import Onyx, {withOnyx} from 'react-native-onyx';
import type {ValueOf} from 'type-fest';
Expand Down Expand Up @@ -281,16 +281,13 @@ function AuthScreens({session, lastOpenedPublicRoomID, initialLastUpdateIDApplie
PusherConnectionManager.init();
initializePusher();

// In Hybrid App we decide to call one of those method when booting ND and we don't want to duplicate calls
if (!NativeModules.HybridAppModule) {
// If we are on this screen then we are "logged in", but the user might not have "just logged in". They could be reopening the app
// or returning from background. If so, we'll assume they have some app data already and we can call reconnectApp() instead of openApp().
if (SessionUtils.didUserLogInDuringSession()) {
App.openApp();
} else {
Log.info('[AuthScreens] Sending ReconnectApp');
App.reconnectApp(initialLastUpdateIDAppliedToClient);
}
// If we are on this screen then we are "logged in", but the user might not have "just logged in". They could be reopening the app
// or returning from background. If so, we'll assume they have some app data already and we can call reconnectApp() instead of openApp().
if (SessionUtils.didUserLogInDuringSession()) {
App.openApp();
} else {
Log.info('[AuthScreens] Sending ReconnectApp');
App.reconnectApp(initialLastUpdateIDAppliedToClient);
}

PriorityMode.autoSwitchToFocusMode();
Expand Down
4 changes: 1 addition & 3 deletions src/libs/Navigation/AppNavigator/PublicScreens.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import React from 'react';
import {NativeModules} from 'react-native';
import createPlatformStackNavigator from '@libs/Navigation/PlatformStackNavigation/createPlatformStackNavigator';
import type {PublicScreensParamList} from '@navigation/types';
import ConnectionCompletePage from '@pages/ConnectionCompletePage';
import SessionExpiredPage from '@pages/ErrorPage/SessionExpiredPage';
import LogInWithShortLivedAuthTokenPage from '@pages/LogInWithShortLivedAuthTokenPage';
import AppleSignInDesktopPage from '@pages/signin/AppleSignInDesktopPage';
import GoogleSignInDesktopPage from '@pages/signin/GoogleSignInDesktopPage';
Expand All @@ -23,7 +21,7 @@ function PublicScreens() {
{/* The structure for the HOME route has to be the same in public and auth screens. That's why the name for SignInPage is BOTTOM_TAB_NAVIGATOR. */}
<RootStack.Screen
name={NAVIGATORS.BOTTOM_TAB_NAVIGATOR}
component={NativeModules.HybridAppModule ? SessionExpiredPage : SignInPage}
component={SignInPage}
/>
<RootStack.Screen
name={SCREENS.TRANSITION_BETWEEN_APPS}
Expand Down
Loading
Loading