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

Fix Use two-factor authentication code and Use recovery codes text blinks #49630

Merged
Merged
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
36 changes: 8 additions & 28 deletions src/pages/signin/ValidateCodeForm/BaseValidateCodeForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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<Account>;

/** The credentials of the person logging in */
credentials: OnyxEntry<Credentials>;

/** Session info for the currently logged in user. */
session: OnyxEntry<Session>;
};

type BaseValidateCodeFormProps = WithToggleVisibilityViewProps &
ValidateCodeFormProps &
BaseValidateCodeFormOnyxProps & {
ValidateCodeFormProps & {
/** Specifies autocomplete hints for the system, so it can provide autofill */
autoComplete: 'sms-otp' | 'one-time-code';
};
Expand All @@ -60,10 +46,10 @@ type ValidateCodeFormVariant = 'validateCode' | 'twoFactorAuthCode' | 'recoveryC

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

function BaseValidateCodeForm(
{account, credentials, session, autoComplete, isUsingRecoveryCode, setIsUsingRecoveryCode, isVisible}: BaseValidateCodeFormProps,
forwardedRef: ForwardedRef<BaseValidateCodeFormRef>,
) {
function BaseValidateCodeForm({autoComplete, isUsingRecoveryCode, setIsUsingRecoveryCode, isVisible}: BaseValidateCodeFormProps, forwardedRef: ForwardedRef<BaseValidateCodeFormRef>) {
const [account] = useOnyx(ONYXKEYS.ACCOUNT);
const [credentials] = useOnyx(ONYXKEYS.CREDENTIALS);
const [session] = useOnyx(ONYXKEYS.SESSION);
const styles = useThemeStyles();
const StyleUtils = useStyleUtils();
const {translate} = useLocalize();
Expand Down Expand Up @@ -345,10 +331,10 @@ function BaseValidateCodeForm(
)}
{hasError && <FormHelpMessage message={ErrorUtils.getLatestErrorMessage(account)} />}
<PressableWithFeedback
key={isUsingRecoveryCode.toString()}
style={[styles.mt2]}
onPress={switchBetween2faAndRecoveryCode}
hoverDimmingValue={1}
pressDimmingValue={0.2}
disabled={isValidateCodeFormSubmitting}
role={CONST.ROLE.BUTTON}
accessibilityLabel={isUsingRecoveryCode ? translate('recoveryCodeForm.use2fa') : translate('recoveryCodeForm.useRecoveryCode')}
Expand Down Expand Up @@ -422,12 +408,6 @@ function BaseValidateCodeForm(

BaseValidateCodeForm.displayName = 'BaseValidateCodeForm';

export default withToggleVisibilityView(
withOnyx<BaseValidateCodeFormProps, BaseValidateCodeFormOnyxProps>({
account: {key: ONYXKEYS.ACCOUNT},
credentials: {key: ONYXKEYS.CREDENTIALS},
session: {key: ONYXKEYS.SESSION},
})(forwardRef(BaseValidateCodeForm)),
);
export default withToggleVisibilityView(forwardRef(BaseValidateCodeForm));

export type {BaseValidateCodeFormRef};
Loading