Skip to content

Commit 3b8c760

Browse files
authored
Merge pull request #49630 from bernhardoj/fix/48712-use-recovery-text-blinking
Fix Use two-factor authentication code and Use recovery codes text blinks
2 parents 7439eda + 8be7923 commit 3b8c760

File tree

1 file changed

+8
-28
lines changed

1 file changed

+8
-28
lines changed

Diff for: src/pages/signin/ValidateCodeForm/BaseValidateCodeForm.tsx

+8-28
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@ import {useIsFocused} from '@react-navigation/native';
22
import React, {forwardRef, useCallback, useEffect, useImperativeHandle, useRef, useState} from 'react';
33
import type {ForwardedRef} from 'react';
44
import {View} from 'react-native';
5-
import type {OnyxEntry} from 'react-native-onyx';
6-
import {withOnyx} from 'react-native-onyx';
5+
import {useOnyx} from 'react-native-onyx';
76
import Button from '@components/Button';
87
import SafariFormWrapper from '@components/Form/SafariFormWrapper';
98
import FormHelpMessage from '@components/FormHelpMessage';
@@ -30,24 +29,11 @@ import * as User from '@userActions/User';
3029
import CONST from '@src/CONST';
3130
import type {TranslationPaths} from '@src/languages/types';
3231
import ONYXKEYS from '@src/ONYXKEYS';
33-
import type {Account, Credentials, Session} from '@src/types/onyx';
3432
import {isEmptyObject} from '@src/types/utils/EmptyObject';
3533
import type ValidateCodeFormProps from './types';
3634

37-
type BaseValidateCodeFormOnyxProps = {
38-
/** The details about the account that the user is signing in with */
39-
account: OnyxEntry<Account>;
40-
41-
/** The credentials of the person logging in */
42-
credentials: OnyxEntry<Credentials>;
43-
44-
/** Session info for the currently logged in user. */
45-
session: OnyxEntry<Session>;
46-
};
47-
4835
type BaseValidateCodeFormProps = WithToggleVisibilityViewProps &
49-
ValidateCodeFormProps &
50-
BaseValidateCodeFormOnyxProps & {
36+
ValidateCodeFormProps & {
5137
/** Specifies autocomplete hints for the system, so it can provide autofill */
5238
autoComplete: 'sms-otp' | 'one-time-code';
5339
};
@@ -60,10 +46,10 @@ type ValidateCodeFormVariant = 'validateCode' | 'twoFactorAuthCode' | 'recoveryC
6046

6147
type FormError = Partial<Record<ValidateCodeFormVariant, TranslationPaths>>;
6248

63-
function BaseValidateCodeForm(
64-
{account, credentials, session, autoComplete, isUsingRecoveryCode, setIsUsingRecoveryCode, isVisible}: BaseValidateCodeFormProps,
65-
forwardedRef: ForwardedRef<BaseValidateCodeFormRef>,
66-
) {
49+
function BaseValidateCodeForm({autoComplete, isUsingRecoveryCode, setIsUsingRecoveryCode, isVisible}: BaseValidateCodeFormProps, forwardedRef: ForwardedRef<BaseValidateCodeFormRef>) {
50+
const [account] = useOnyx(ONYXKEYS.ACCOUNT);
51+
const [credentials] = useOnyx(ONYXKEYS.CREDENTIALS);
52+
const [session] = useOnyx(ONYXKEYS.SESSION);
6753
const styles = useThemeStyles();
6854
const StyleUtils = useStyleUtils();
6955
const {translate} = useLocalize();
@@ -345,10 +331,10 @@ function BaseValidateCodeForm(
345331
)}
346332
{hasError && <FormHelpMessage message={ErrorUtils.getLatestErrorMessage(account)} />}
347333
<PressableWithFeedback
334+
key={isUsingRecoveryCode.toString()}
348335
style={[styles.mt2]}
349336
onPress={switchBetween2faAndRecoveryCode}
350337
hoverDimmingValue={1}
351-
pressDimmingValue={0.2}
352338
disabled={isValidateCodeFormSubmitting}
353339
role={CONST.ROLE.BUTTON}
354340
accessibilityLabel={isUsingRecoveryCode ? translate('recoveryCodeForm.use2fa') : translate('recoveryCodeForm.useRecoveryCode')}
@@ -422,12 +408,6 @@ function BaseValidateCodeForm(
422408

423409
BaseValidateCodeForm.displayName = 'BaseValidateCodeForm';
424410

425-
export default withToggleVisibilityView(
426-
withOnyx<BaseValidateCodeFormProps, BaseValidateCodeFormOnyxProps>({
427-
account: {key: ONYXKEYS.ACCOUNT},
428-
credentials: {key: ONYXKEYS.CREDENTIALS},
429-
session: {key: ONYXKEYS.SESSION},
430-
})(forwardRef(BaseValidateCodeForm)),
431-
);
411+
export default withToggleVisibilityView(forwardRef(BaseValidateCodeForm));
432412

433413
export type {BaseValidateCodeFormRef};

0 commit comments

Comments
 (0)