From 2332436f4b6913f3f6f4895db799bc17768a834f Mon Sep 17 00:00:00 2001 From: Bernhard Owen Josephus Date: Tue, 24 Sep 2024 14:36:16 +0800 Subject: [PATCH 1/2] fix text blinking --- src/pages/signin/ValidateCodeForm/BaseValidateCodeForm.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/signin/ValidateCodeForm/BaseValidateCodeForm.tsx b/src/pages/signin/ValidateCodeForm/BaseValidateCodeForm.tsx index f23b136c76d0..6b803b42302b 100755 --- a/src/pages/signin/ValidateCodeForm/BaseValidateCodeForm.tsx +++ b/src/pages/signin/ValidateCodeForm/BaseValidateCodeForm.tsx @@ -345,10 +345,10 @@ function BaseValidateCodeForm( )} {hasError && } Date: Tue, 24 Sep 2024 14:59:04 +0800 Subject: [PATCH 2/2] migrate to useOnyx --- .../ValidateCodeForm/BaseValidateCodeForm.tsx | 34 ++++--------------- 1 file changed, 7 insertions(+), 27 deletions(-) diff --git a/src/pages/signin/ValidateCodeForm/BaseValidateCodeForm.tsx b/src/pages/signin/ValidateCodeForm/BaseValidateCodeForm.tsx index 6b803b42302b..f73c0a1602fb 100755 --- a/src/pages/signin/ValidateCodeForm/BaseValidateCodeForm.tsx +++ b/src/pages/signin/ValidateCodeForm/BaseValidateCodeForm.tsx @@ -2,8 +2,7 @@ import {useIsFocused} from '@react-navigation/native'; 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'; +import {useOnyx} from 'react-native-onyx'; import Button from '@components/Button'; import SafariFormWrapper from '@components/Form/SafariFormWrapper'; import FormHelpMessage from '@components/FormHelpMessage'; @@ -30,24 +29,11 @@ import * as User from '@userActions/User'; import CONST from '@src/CONST'; import type {TranslationPaths} from '@src/languages/types'; import ONYXKEYS from '@src/ONYXKEYS'; -import type {Account, Credentials, Session} from '@src/types/onyx'; import {isEmptyObject} from '@src/types/utils/EmptyObject'; import type ValidateCodeFormProps from './types'; -type BaseValidateCodeFormOnyxProps = { - /** The details about the account that the user is signing in with */ - account: OnyxEntry; - - /** The credentials of the person logging in */ - credentials: OnyxEntry; - - /** Session info for the currently logged in user. */ - session: OnyxEntry; -}; - type BaseValidateCodeFormProps = WithToggleVisibilityViewProps & - ValidateCodeFormProps & - BaseValidateCodeFormOnyxProps & { + ValidateCodeFormProps & { /** Specifies autocomplete hints for the system, so it can provide autofill */ autoComplete: 'sms-otp' | 'one-time-code'; }; @@ -60,10 +46,10 @@ type ValidateCodeFormVariant = 'validateCode' | 'twoFactorAuthCode' | 'recoveryC type FormError = Partial>; -function BaseValidateCodeForm( - {account, credentials, session, autoComplete, isUsingRecoveryCode, setIsUsingRecoveryCode, isVisible}: BaseValidateCodeFormProps, - forwardedRef: ForwardedRef, -) { +function BaseValidateCodeForm({autoComplete, isUsingRecoveryCode, setIsUsingRecoveryCode, isVisible}: BaseValidateCodeFormProps, forwardedRef: ForwardedRef) { + const [account] = useOnyx(ONYXKEYS.ACCOUNT); + const [credentials] = useOnyx(ONYXKEYS.CREDENTIALS); + const [session] = useOnyx(ONYXKEYS.SESSION); const styles = useThemeStyles(); const StyleUtils = useStyleUtils(); const {translate} = useLocalize(); @@ -422,12 +408,6 @@ function BaseValidateCodeForm( BaseValidateCodeForm.displayName = 'BaseValidateCodeForm'; -export default withToggleVisibilityView( - withOnyx({ - account: {key: ONYXKEYS.ACCOUNT}, - credentials: {key: ONYXKEYS.CREDENTIALS}, - session: {key: ONYXKEYS.SESSION}, - })(forwardRef(BaseValidateCodeForm)), -); +export default withToggleVisibilityView(forwardRef(BaseValidateCodeForm)); export type {BaseValidateCodeFormRef};