From 57a1ce3b1eedf02b0e47898179d2315b5a948d7b Mon Sep 17 00:00:00 2001 From: krishna2323 Date: Sat, 3 Aug 2024 15:59:41 +0530 Subject: [PATCH 1/6] fix: Room - Sign in RHP disappears after clicking on the '<' button. Signed-off-by: krishna2323 --- src/pages/signin/EmailDeliveryFailurePage.tsx | 11 +++++++- src/pages/signin/SignInModal.tsx | 7 ++--- src/pages/signin/SignInPage.tsx | 26 ++++++++++++++++++- src/pages/signin/SignUpWelcomeForm.tsx | 6 +++++ .../ValidateCodeForm/BaseValidateCodeForm.tsx | 14 ++++++---- src/pages/signin/ValidateCodeForm/types.ts | 3 +++ 6 files changed, 57 insertions(+), 10 deletions(-) diff --git a/src/pages/signin/EmailDeliveryFailurePage.tsx b/src/pages/signin/EmailDeliveryFailurePage.tsx index 0a294e3a6b86..b88f6766e24a 100644 --- a/src/pages/signin/EmailDeliveryFailurePage.tsx +++ b/src/pages/signin/EmailDeliveryFailurePage.tsx @@ -9,9 +9,12 @@ import TextLink from '@components/TextLink'; import useKeyboardState from '@hooks/useKeyboardState'; import useLocalize from '@hooks/useLocalize'; import useThemeStyles from '@hooks/useThemeStyles'; +import Navigation from '@libs/Navigation/Navigation'; +import * as Session from '@userActions/Session'; import redirectToSignIn from '@userActions/SignInRedirect'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; +import ROUTES from '@src/ROUTES'; import type {Credentials} from '@src/types/onyx'; type EmailDeliveryFailurePageOnyxProps = { @@ -74,7 +77,13 @@ function EmailDeliveryFailurePage({credentials}: EmailDeliveryFailurePageProps) redirectToSignIn()} + onPress={() => { + if (Navigation.isActiveRoute(ROUTES.SIGN_IN_MODAL)) { + Session.clearSignInData(); + return; + } + redirectToSignIn(); + }} role="button" accessibilityLabel={translate('common.back')} // disable hover dim for switch diff --git a/src/pages/signin/SignInModal.tsx b/src/pages/signin/SignInModal.tsx index 5bce895ab251..3db390b162c1 100644 --- a/src/pages/signin/SignInModal.tsx +++ b/src/pages/signin/SignInModal.tsx @@ -1,7 +1,6 @@ import React, {useEffect} from 'react'; import type {OnyxEntry} from 'react-native-onyx'; import {withOnyx} from 'react-native-onyx'; -import HeaderWithBackButton from '@components/HeaderWithBackButton'; import ScreenWrapper from '@components/ScreenWrapper'; import useStyleUtils from '@hooks/useStyleUtils'; import useTheme from '@hooks/useTheme'; @@ -40,8 +39,10 @@ function SignInModal({session}: SignInModalProps) { shouldShowOfflineIndicator={false} testID={SignInModal.displayName} > - Navigation.goBack()} /> - + ); } diff --git a/src/pages/signin/SignInPage.tsx b/src/pages/signin/SignInPage.tsx index 024d5a7c5610..a5230ac0f708 100644 --- a/src/pages/signin/SignInPage.tsx +++ b/src/pages/signin/SignInPage.tsx @@ -4,6 +4,7 @@ import {withOnyx} from 'react-native-onyx'; import type {OnyxEntry} from 'react-native-onyx'; import ColorSchemeWrapper from '@components/ColorSchemeWrapper'; import CustomStatusBarAndBackground from '@components/CustomStatusBarAndBackground'; +import HeaderWithBackButton from '@components/HeaderWithBackButton'; import ScreenWrapper from '@components/ScreenWrapper'; import ThemeProvider from '@components/ThemeProvider'; import ThemeStylesProvider from '@components/ThemeStylesProvider'; @@ -51,6 +52,7 @@ type SignInPageInnerOnyxProps = { type SignInPageInnerProps = SignInPageInnerOnyxProps & { shouldEnableMaxHeight?: boolean; + shouldShowBackButton?: boolean; }; type RenderOption = { @@ -141,7 +143,7 @@ function getRenderOptions({ }; } -function SignInPage({credentials, account, activeClients = [], preferredLocale, shouldEnableMaxHeight = true}: SignInPageInnerProps) { +function SignInPage({credentials, account, activeClients = [], preferredLocale, shouldEnableMaxHeight = true, shouldShowBackButton}: SignInPageInnerProps) { const styles = useThemeStyles(); const StyleUtils = useStyleUtils(); const {translate, formatPhoneNumber} = useLocalize(); @@ -149,6 +151,7 @@ function SignInPage({credentials, account, activeClients = [], preferredLocale, const safeAreaInsets = useSafeAreaInsets(); const signInPageLayoutRef = useRef(null); const loginFormRef = useRef(null); + const clearValidateCodeFormDataRef = useRef<() => void>(null); /** This state is needed to keep track of if user is using recovery code instead of 2fa code, * and we need it here since welcome text(`welcomeText`) also depends on it */ const [isUsingRecoveryCode, setIsUsingRecoveryCode] = useState(false); @@ -260,6 +263,23 @@ function SignInPage({credentials, account, activeClients = [], preferredLocale, loginFormRef.current?.clearDataAndFocus(); }; + const navigateBack = () => { + if ( + shouldShouldSignUpWelcomeForm || + (!shouldShowAnotherLoginPageOpenedMessage && (shouldShowEmailDeliveryFailurePage || shouldShowUnlinkLoginForm || shouldShowChooseSSOOrMagicCode)) + ) { + Session.clearSignInData(); + return; + } + + if (shouldShowValidateCodeForm) { + clearValidateCodeFormDataRef?.current?.(); + return; + } + + Navigation.goBack(); + }; + return ( // Bottom SafeAreaView is removed so that login screen svg displays correctly on mobile. // The SVG should flow under the Home Indicator on iOS. @@ -270,6 +290,7 @@ function SignInPage({credentials, account, activeClients = [], preferredLocale, style={[styles.signInPage, StyleUtils.getSafeAreaPadding({...safeAreaInsets, bottom: 0, top: isInNarrowPaneModal ? 0 : safeAreaInsets.top}, 1)]} testID={SignInPageThemeWrapper.displayName} > + {shouldShowBackButton && } void) => { + (clearValidateCodeFormDataRef.current as (() => void) | null) = clearSignInData; + }} /> )} {!shouldShowAnotherLoginPageOpenedMessage && ( diff --git a/src/pages/signin/SignUpWelcomeForm.tsx b/src/pages/signin/SignUpWelcomeForm.tsx index 1d8010be14cb..db27ab52fb88 100644 --- a/src/pages/signin/SignUpWelcomeForm.tsx +++ b/src/pages/signin/SignUpWelcomeForm.tsx @@ -6,9 +6,11 @@ import Button from '@components/Button'; import useLocalize from '@hooks/useLocalize'; import useNetwork from '@hooks/useNetwork'; import useThemeStyles from '@hooks/useThemeStyles'; +import Navigation from '@libs/Navigation/Navigation'; import * as Session from '@userActions/Session'; import redirectToSignIn from '@userActions/SignInRedirect'; import ONYXKEYS from '@src/ONYXKEYS'; +import ROUTES from '@src/ROUTES'; import type {Account} from '@src/types/onyx'; import ChangeExpensifyLoginLink from './ChangeExpensifyLoginLink'; import Terms from './Terms'; @@ -40,6 +42,10 @@ function SignUpWelcomeForm({account}: SignUpWelcomeFormProps) { /> { + if (Navigation.isActiveRoute(ROUTES.SIGN_IN_MODAL)) { + Session.clearSignInData(); + return; + } redirectToSignIn(); }} /> diff --git a/src/pages/signin/ValidateCodeForm/BaseValidateCodeForm.tsx b/src/pages/signin/ValidateCodeForm/BaseValidateCodeForm.tsx index bf0be21adb97..0828db1e96f7 100755 --- a/src/pages/signin/ValidateCodeForm/BaseValidateCodeForm.tsx +++ b/src/pages/signin/ValidateCodeForm/BaseValidateCodeForm.tsx @@ -55,7 +55,7 @@ type ValidateCodeFormVariant = 'validateCode' | 'twoFactorAuthCode' | 'recoveryC type FormError = Partial>; -function BaseValidateCodeForm({account, credentials, session, autoComplete, isUsingRecoveryCode, setIsUsingRecoveryCode, isVisible}: BaseValidateCodeFormProps) { +function BaseValidateCodeForm({account, credentials, session, autoComplete, isUsingRecoveryCode, setIsUsingRecoveryCode, isVisible, setClearSignInData}: BaseValidateCodeFormProps) { const styles = useThemeStyles(); const StyleUtils = useStyleUtils(); const {translate} = useLocalize(); @@ -168,21 +168,25 @@ function BaseValidateCodeForm({account, credentials, session, autoComplete, isUs /** * Clear local sign in states */ - const clearLocalSignInData = () => { + const clearLocalSignInData = useCallback(() => { setTwoFactorAuthCode(''); setFormError({}); setValidateCode(''); setIsUsingRecoveryCode(false); setRecoveryCode(''); - }; + }, [setIsUsingRecoveryCode]); /** * Clears local and Onyx sign in states */ - const clearSignInData = () => { + const clearSignInData = useCallback(() => { clearLocalSignInData(); SessionActions.clearSignInData(); - }; + }, [clearLocalSignInData]); + + useEffect(() => { + setClearSignInData(clearSignInData); + }, [clearSignInData, setClearSignInData]); useEffect(() => { if (!needToClearError) { diff --git a/src/pages/signin/ValidateCodeForm/types.ts b/src/pages/signin/ValidateCodeForm/types.ts index 6edb6eace231..347116be286a 100644 --- a/src/pages/signin/ValidateCodeForm/types.ts +++ b/src/pages/signin/ValidateCodeForm/types.ts @@ -6,6 +6,9 @@ type ValidateCodeFormProps = { setIsUsingRecoveryCode: (value: boolean) => void; isVisible: boolean; + + /** Function to clear the credentials and partial sign in session so the user can taken back to first Login step */ + setClearSignInData: (clearSignInData: () => void) => void; }; export default ValidateCodeFormProps; From febd1efebe4a2b07a73388e0004ec683d040e0fc Mon Sep 17 00:00:00 2001 From: krishna2323 Date: Sun, 11 Aug 2024 18:00:51 +0530 Subject: [PATCH 2/6] Use useImperativeHandle. --- src/pages/signin/SignInModal.tsx | 16 +++++++- src/pages/signin/SignInPage.tsx | 41 ++++++++++++------- .../ValidateCodeForm/BaseValidateCodeForm.tsx | 22 +++++++--- src/pages/signin/ValidateCodeForm/index.tsx | 9 ++-- src/pages/signin/ValidateCodeForm/types.ts | 3 -- 5 files changed, 62 insertions(+), 29 deletions(-) diff --git a/src/pages/signin/SignInModal.tsx b/src/pages/signin/SignInModal.tsx index 3db390b162c1..bad93b29f8af 100644 --- a/src/pages/signin/SignInModal.tsx +++ b/src/pages/signin/SignInModal.tsx @@ -1,6 +1,7 @@ -import React, {useEffect} from 'react'; +import React, {useEffect, useRef} from 'react'; import type {OnyxEntry} from 'react-native-onyx'; import {withOnyx} from 'react-native-onyx'; +import HeaderWithBackButton from '@components/HeaderWithBackButton'; import ScreenWrapper from '@components/ScreenWrapper'; import useStyleUtils from '@hooks/useStyleUtils'; import useTheme from '@hooks/useTheme'; @@ -11,6 +12,7 @@ import ONYXKEYS from '@src/ONYXKEYS'; import SCREENS from '@src/SCREENS'; import type {Session} from '@src/types/onyx'; import SignInPage from './SignInPage'; +import type {SignInPageRef} from './SignInPage'; type SignInModalOnyxProps = { session: OnyxEntry; @@ -21,6 +23,7 @@ type SignInModalProps = SignInModalOnyxProps; function SignInModal({session}: SignInModalProps) { const theme = useTheme(); const StyleUtils = useStyleUtils(); + const siginPageRef = useRef(null); useEffect(() => { const isAnonymousUser = session?.authTokenType === CONST.AUTH_TOKEN_TYPES.ANONYMOUS; @@ -39,9 +42,18 @@ function SignInModal({session}: SignInModalProps) { shouldShowOfflineIndicator={false} testID={SignInModal.displayName} > + { + if (!siginPageRef.current) { + Navigation.goBack(); + return; + } + siginPageRef.current?.navigateBack(); + }} + /> ); diff --git a/src/pages/signin/SignInPage.tsx b/src/pages/signin/SignInPage.tsx index 8f10835cbfc5..687a3ecca630 100644 --- a/src/pages/signin/SignInPage.tsx +++ b/src/pages/signin/SignInPage.tsx @@ -1,10 +1,10 @@ import {Str} from 'expensify-common'; -import React, {useEffect, useRef, useState} from 'react'; +import React, {forwardRef, useEffect, useImperativeHandle, useRef, useState} from 'react'; +import type {ForwardedRef, RefAttributes} from 'react'; import {withOnyx} from 'react-native-onyx'; import type {OnyxEntry} from 'react-native-onyx'; import ColorSchemeWrapper from '@components/ColorSchemeWrapper'; import CustomStatusBarAndBackground from '@components/CustomStatusBarAndBackground'; -import HeaderWithBackButton from '@components/HeaderWithBackButton'; import ScreenWrapper from '@components/ScreenWrapper'; import ThemeProvider from '@components/ThemeProvider'; import ThemeStylesProvider from '@components/ThemeStylesProvider'; @@ -35,6 +35,7 @@ import type {SignInPageLayoutRef} from './SignInPageLayout/types'; import SignUpWelcomeForm from './SignUpWelcomeForm'; import UnlinkLoginForm from './UnlinkLoginForm'; import ValidateCodeForm from './ValidateCodeForm'; +import type {BaseValidateCodeFormRef} from './ValidateCodeForm/BaseValidateCodeForm'; type SignInPageInnerOnyxProps = { /** The details about the account that the user is signing in with */ @@ -52,7 +53,10 @@ type SignInPageInnerOnyxProps = { type SignInPageInnerProps = SignInPageInnerOnyxProps & { shouldEnableMaxHeight?: boolean; - shouldShowBackButton?: boolean; +}; + +type SignInPageRef = { + navigateBack: () => void; }; type RenderOption = { @@ -143,7 +147,10 @@ function getRenderOptions({ }; } -function SignInPage({credentials, account, activeClients = [], preferredLocale, shouldEnableMaxHeight = true, shouldShowBackButton}: SignInPageInnerProps) { +const SignInPage = forwardRef(function SignInPage( + {credentials, account, activeClients = [], preferredLocale, shouldEnableMaxHeight = true}: SignInPageInnerProps, + ref: ForwardedRef, +) { const styles = useThemeStyles(); const StyleUtils = useStyleUtils(); const {translate, formatPhoneNumber} = useLocalize(); @@ -151,7 +158,8 @@ function SignInPage({credentials, account, activeClients = [], preferredLocale, const safeAreaInsets = useSafeAreaInsets(); const signInPageLayoutRef = useRef(null); const loginFormRef = useRef(null); - const clearValidateCodeFormDataRef = useRef<() => void>(null); + const validateCodeFormRef = useRef(null); + /** This state is needed to keep track of if user is using recovery code instead of 2fa code, * and we need it here since welcome text(`welcomeText`) also depends on it */ const [isUsingRecoveryCode, setIsUsingRecoveryCode] = useState(false); @@ -275,13 +283,15 @@ function SignInPage({credentials, account, activeClients = [], preferredLocale, } if (shouldShowValidateCodeForm) { - clearValidateCodeFormDataRef?.current?.(); + validateCodeFormRef.current?.clearSignInData(); return; } Navigation.goBack(); }; - + useImperativeHandle(ref, () => ({ + navigateBack, + })); return ( // Bottom SafeAreaView is removed so that login screen svg displays correctly on mobile. // The SVG should flow under the Home Indicator on iOS. @@ -292,7 +302,7 @@ function SignInPage({credentials, account, activeClients = [], preferredLocale, style={[styles.signInPage, StyleUtils.getSafeAreaPadding({...safeAreaInsets, bottom: 0, top: isInNarrowPaneModal ? 0 : safeAreaInsets.top}, 1)]} testID={SignInPageThemeWrapper.displayName} > - {shouldShowBackButton && } + {/* {shouldShowBackButton && } */} void) => { - (clearValidateCodeFormDataRef.current as (() => void) | null) = clearSignInData; - }} + ref={validateCodeFormRef} /> )} {!shouldShowAnotherLoginPageOpenedMessage && ( @@ -332,18 +340,19 @@ function SignInPage({credentials, account, activeClients = [], preferredLocale, ); -} +}); type SignInPageProps = SignInPageInnerProps; type SignInPageOnyxProps = SignInPageInnerOnyxProps; -function SignInPageThemeWrapper(props: SignInPageProps) { +function SignInPageThemeWrapper(props: SignInPageProps, ref: ForwardedRef) { return ( @@ -355,7 +364,7 @@ function SignInPageThemeWrapper(props: SignInPageProps) { SignInPageThemeWrapper.displayName = 'SignInPage'; -export default withOnyx({ +export default withOnyx, SignInPageOnyxProps>({ account: {key: ONYXKEYS.ACCOUNT}, credentials: {key: ONYXKEYS.CREDENTIALS}, /** @@ -369,4 +378,6 @@ export default withOnyx({ preferredLocale: { key: ONYXKEYS.NVP_PREFERRED_LOCALE, }, -})(SignInPageThemeWrapper); +})(forwardRef(SignInPageThemeWrapper)); + +export type {SignInPageRef}; diff --git a/src/pages/signin/ValidateCodeForm/BaseValidateCodeForm.tsx b/src/pages/signin/ValidateCodeForm/BaseValidateCodeForm.tsx index 0828db1e96f7..f23b136c76d0 100755 --- a/src/pages/signin/ValidateCodeForm/BaseValidateCodeForm.tsx +++ b/src/pages/signin/ValidateCodeForm/BaseValidateCodeForm.tsx @@ -1,5 +1,6 @@ import {useIsFocused} from '@react-navigation/native'; -import React, {useCallback, useEffect, useRef, useState} from 'react'; +import React, {forwardRef, useCallback, useEffect, useImperativeHandle, useRef, useState} from 'react'; +import type {ForwardedRef} from 'react'; import {View} from 'react-native'; import type {OnyxEntry} from 'react-native-onyx'; import {withOnyx} from 'react-native-onyx'; @@ -51,11 +52,18 @@ type BaseValidateCodeFormProps = WithToggleVisibilityViewProps & autoComplete: 'sms-otp' | 'one-time-code'; }; +type BaseValidateCodeFormRef = { + clearSignInData: () => void; +}; + type ValidateCodeFormVariant = 'validateCode' | 'twoFactorAuthCode' | 'recoveryCode'; type FormError = Partial>; -function BaseValidateCodeForm({account, credentials, session, autoComplete, isUsingRecoveryCode, setIsUsingRecoveryCode, isVisible, setClearSignInData}: BaseValidateCodeFormProps) { +function BaseValidateCodeForm( + {account, credentials, session, autoComplete, isUsingRecoveryCode, setIsUsingRecoveryCode, isVisible}: BaseValidateCodeFormProps, + forwardedRef: ForwardedRef, +) { const styles = useThemeStyles(); const StyleUtils = useStyleUtils(); const {translate} = useLocalize(); @@ -184,9 +192,9 @@ function BaseValidateCodeForm({account, credentials, session, autoComplete, isUs SessionActions.clearSignInData(); }, [clearLocalSignInData]); - useEffect(() => { - setClearSignInData(clearSignInData); - }, [clearSignInData, setClearSignInData]); + useImperativeHandle(forwardedRef, () => ({ + clearSignInData, + })); useEffect(() => { if (!needToClearError) { @@ -419,5 +427,7 @@ export default withToggleVisibilityView( account: {key: ONYXKEYS.ACCOUNT}, credentials: {key: ONYXKEYS.CREDENTIALS}, session: {key: ONYXKEYS.SESSION}, - })(BaseValidateCodeForm), + })(forwardRef(BaseValidateCodeForm)), ); + +export type {BaseValidateCodeFormRef}; diff --git a/src/pages/signin/ValidateCodeForm/index.tsx b/src/pages/signin/ValidateCodeForm/index.tsx index 8c1528ae7409..c656b049345e 100644 --- a/src/pages/signin/ValidateCodeForm/index.tsx +++ b/src/pages/signin/ValidateCodeForm/index.tsx @@ -1,11 +1,14 @@ -import React from 'react'; +import React, {forwardRef} from 'react'; +import type {ForwardedRef} from 'react'; import BaseValidateCodeForm from './BaseValidateCodeForm'; +import type {BaseValidateCodeFormRef} from './BaseValidateCodeForm'; import type ValidateCodeFormProps from './types'; -function ValidateCodeForm(props: ValidateCodeFormProps) { +function ValidateCodeForm(props: ValidateCodeFormProps, ref: ForwardedRef) { return ( @@ -14,4 +17,4 @@ function ValidateCodeForm(props: ValidateCodeFormProps) { ValidateCodeForm.displayName = 'ValidateCodeForm'; -export default ValidateCodeForm; +export default forwardRef(ValidateCodeForm); diff --git a/src/pages/signin/ValidateCodeForm/types.ts b/src/pages/signin/ValidateCodeForm/types.ts index 347116be286a..6edb6eace231 100644 --- a/src/pages/signin/ValidateCodeForm/types.ts +++ b/src/pages/signin/ValidateCodeForm/types.ts @@ -6,9 +6,6 @@ type ValidateCodeFormProps = { setIsUsingRecoveryCode: (value: boolean) => void; isVisible: boolean; - - /** Function to clear the credentials and partial sign in session so the user can taken back to first Login step */ - setClearSignInData: (clearSignInData: () => void) => void; }; export default ValidateCodeFormProps; From fa5790c8a99a094a3c54c7ee6b8bf50f69211f92 Mon Sep 17 00:00:00 2001 From: krishna2323 Date: Sun, 11 Aug 2024 18:38:06 +0530 Subject: [PATCH 3/6] pass ref for android. Signed-off-by: krishna2323 --- src/pages/signin/ValidateCodeForm/index.android.tsx | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/pages/signin/ValidateCodeForm/index.android.tsx b/src/pages/signin/ValidateCodeForm/index.android.tsx index 1edd17517539..1cb05a0470f0 100644 --- a/src/pages/signin/ValidateCodeForm/index.android.tsx +++ b/src/pages/signin/ValidateCodeForm/index.android.tsx @@ -1,11 +1,14 @@ -import React from 'react'; +import React, {forwardRef} from 'react'; +import type {ForwardedRef} from 'react'; import BaseValidateCodeForm from './BaseValidateCodeForm'; +import type {BaseValidateCodeFormRef} from './BaseValidateCodeForm'; import type ValidateCodeFormProps from './types'; -function ValidateCodeForm(props: ValidateCodeFormProps) { +function ValidateCodeForm(props: ValidateCodeFormProps, ref: ForwardedRef) { return ( @@ -14,4 +17,4 @@ function ValidateCodeForm(props: ValidateCodeFormProps) { ValidateCodeForm.displayName = 'ValidateCodeForm'; -export default ValidateCodeForm; +export default forwardRef(ValidateCodeForm); From 9ac2d06ac6b32636c9e61d37c62ac1f52e73681a Mon Sep 17 00:00:00 2001 From: krishna2323 Date: Wed, 14 Aug 2024 04:57:01 +0530 Subject: [PATCH 4/6] use Session.clearSignInData() instead of redirectToSignIn(). Signed-off-by: krishna2323 --- src/pages/signin/EmailDeliveryFailurePage.tsx | 11 +---------- src/pages/signin/SignUpWelcomeForm.tsx | 13 +------------ 2 files changed, 2 insertions(+), 22 deletions(-) diff --git a/src/pages/signin/EmailDeliveryFailurePage.tsx b/src/pages/signin/EmailDeliveryFailurePage.tsx index b88f6766e24a..ff16af7dffd9 100644 --- a/src/pages/signin/EmailDeliveryFailurePage.tsx +++ b/src/pages/signin/EmailDeliveryFailurePage.tsx @@ -9,12 +9,9 @@ import TextLink from '@components/TextLink'; import useKeyboardState from '@hooks/useKeyboardState'; import useLocalize from '@hooks/useLocalize'; import useThemeStyles from '@hooks/useThemeStyles'; -import Navigation from '@libs/Navigation/Navigation'; import * as Session from '@userActions/Session'; -import redirectToSignIn from '@userActions/SignInRedirect'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; -import ROUTES from '@src/ROUTES'; import type {Credentials} from '@src/types/onyx'; type EmailDeliveryFailurePageOnyxProps = { @@ -77,13 +74,7 @@ function EmailDeliveryFailurePage({credentials}: EmailDeliveryFailurePageProps) { - if (Navigation.isActiveRoute(ROUTES.SIGN_IN_MODAL)) { - Session.clearSignInData(); - return; - } - redirectToSignIn(); - }} + onPress={() => Session.clearSignInData()} role="button" accessibilityLabel={translate('common.back')} // disable hover dim for switch diff --git a/src/pages/signin/SignUpWelcomeForm.tsx b/src/pages/signin/SignUpWelcomeForm.tsx index db27ab52fb88..68bb7d10796a 100644 --- a/src/pages/signin/SignUpWelcomeForm.tsx +++ b/src/pages/signin/SignUpWelcomeForm.tsx @@ -6,11 +6,8 @@ import Button from '@components/Button'; import useLocalize from '@hooks/useLocalize'; import useNetwork from '@hooks/useNetwork'; import useThemeStyles from '@hooks/useThemeStyles'; -import Navigation from '@libs/Navigation/Navigation'; import * as Session from '@userActions/Session'; -import redirectToSignIn from '@userActions/SignInRedirect'; import ONYXKEYS from '@src/ONYXKEYS'; -import ROUTES from '@src/ROUTES'; import type {Account} from '@src/types/onyx'; import ChangeExpensifyLoginLink from './ChangeExpensifyLoginLink'; import Terms from './Terms'; @@ -40,15 +37,7 @@ function SignUpWelcomeForm({account}: SignUpWelcomeFormProps) { pressOnEnter style={[styles.mb2]} /> - { - if (Navigation.isActiveRoute(ROUTES.SIGN_IN_MODAL)) { - Session.clearSignInData(); - return; - } - redirectToSignIn(); - }} - /> + Session.clearSignInData()} /> From da2d3cb045c03cbc2bab5cd3cfa779afd2953e69 Mon Sep 17 00:00:00 2001 From: krishna2323 Date: Thu, 15 Aug 2024 01:35:12 +0530 Subject: [PATCH 5/6] remove commented code. Signed-off-by: krishna2323 --- src/pages/signin/SignInPage.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/src/pages/signin/SignInPage.tsx b/src/pages/signin/SignInPage.tsx index 687a3ecca630..9e80e4a44dc6 100644 --- a/src/pages/signin/SignInPage.tsx +++ b/src/pages/signin/SignInPage.tsx @@ -302,7 +302,6 @@ const SignInPage = forwardRef(function SignInPage( style={[styles.signInPage, StyleUtils.getSafeAreaPadding({...safeAreaInsets, bottom: 0, top: isInNarrowPaneModal ? 0 : safeAreaInsets.top}, 1)]} testID={SignInPageThemeWrapper.displayName} > - {/* {shouldShowBackButton && } */} Date: Fri, 16 Aug 2024 03:24:52 +0530 Subject: [PATCH 6/6] cleanup. Signed-off-by: krishna2323 --- src/pages/signin/SignInPage.tsx | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/pages/signin/SignInPage.tsx b/src/pages/signin/SignInPage.tsx index 9e80e4a44dc6..729faae5e90b 100644 --- a/src/pages/signin/SignInPage.tsx +++ b/src/pages/signin/SignInPage.tsx @@ -147,10 +147,7 @@ function getRenderOptions({ }; } -const SignInPage = forwardRef(function SignInPage( - {credentials, account, activeClients = [], preferredLocale, shouldEnableMaxHeight = true}: SignInPageInnerProps, - ref: ForwardedRef, -) { +function SignInPage({credentials, account, activeClients = [], preferredLocale, shouldEnableMaxHeight = true}: SignInPageInnerProps, ref: ForwardedRef) { const styles = useThemeStyles(); const StyleUtils = useStyleUtils(); const {translate, formatPhoneNumber} = useLocalize(); @@ -339,10 +336,11 @@ const SignInPage = forwardRef(function SignInPage( ); -}); +} type SignInPageProps = SignInPageInnerProps; type SignInPageOnyxProps = SignInPageInnerOnyxProps; +const SignInPageWithRef = forwardRef(SignInPage); function SignInPageThemeWrapper(props: SignInPageProps, ref: ForwardedRef) { return ( @@ -350,7 +348,7 @@ function SignInPageThemeWrapper(props: SignInPageProps, ref: ForwardedRef -