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

Update the magic code expired page #45456

Merged
merged 5 commits into from
Jul 26, 2024
Merged
Show file tree
Hide file tree
Changes from 4 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
2 changes: 2 additions & 0 deletions src/CONST.ts
Original file line number Diff line number Diff line change
Expand Up @@ -626,6 +626,8 @@ const CONST = {

SIGN_IN_FORM_WIDTH: 300,

REQUEST_CODE_DELAY: 30,

DEEPLINK_PROMPT_DENYLIST: [SCREENS.HOME, SCREENS.SIGN_IN_WITH_APPLE_DESKTOP, SCREENS.SIGN_IN_WITH_GOOGLE_DESKTOP],

SIGN_IN_METHOD: {
Expand Down
21 changes: 20 additions & 1 deletion src/components/ValidateCode/ExpiredValidateCodeModal.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,23 @@
import React from 'react';
import {View} from 'react-native';
import {useOnyx} from 'react-native-onyx';
import Icon from '@components/Icon';
import * as Expensicons from '@components/Icon/Expensicons';
import * as Illustrations from '@components/Icon/Illustrations';
import Text from '@components/Text';
import TextLink from '@components/TextLink';
import useLocalize from '@hooks/useLocalize';
import useTheme from '@hooks/useTheme';
import useThemeStyles from '@hooks/useThemeStyles';
import Navigation from '@libs/Navigation/Navigation';
import variables from '@styles/variables';
import * as Session from '@userActions/Session';
import ONYXKEYS from '@src/ONYXKEYS';

function ExpiredValidateCodeModal() {
const theme = useTheme();
const styles = useThemeStyles();
const [credentials] = useOnyx(ONYXKEYS.CREDENTIALS);
const {translate} = useLocalize();
return (
<View style={styles.deeplinkWrapperContainer}>
Expand All @@ -25,7 +31,20 @@ function ExpiredValidateCodeModal() {
</View>
<Text style={[styles.textHeadline, styles.textXXLarge, styles.textAlignCenter]}>{translate('validateCodeModal.expiredCodeTitle')}</Text>
<View style={[styles.mt2, styles.mb2]}>
<Text style={styles.textAlignCenter}>{translate('validateCodeModal.expiredCodeDescription')}</Text>
<Text style={styles.textAlignCenter}>
{translate('validateCodeModal.expiredCodeDescription')}
{translate('validateCodeModal.or')}{' '}
<TextLink
onPress={() => {
requestAnimationFrame(() => {
Session.beginSignIn(credentials?.login ?? '');
});
Copy link
Contributor

@ZhenjaHorbach ZhenjaHorbach Jul 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, my fault
Sorry for misleading you 😅
I think we'd better wrap Navigation.goBack instead Session.beginSignIn with an requestAnimationFrame ( Plus we have Navigation.setNavigationActionToMicrotaskQueue which we can use as an alternative to requestAnimationFrame )

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ZhenjaHorbach please check again

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's good now
Thanks for the fix !

Navigation.goBack();
}}
>
{translate('validateCodeModal.requestOneHere')}
</TextLink>
</Text>
</View>
</View>
<View style={styles.deeplinkWrapperFooter}>
Expand Down
3 changes: 2 additions & 1 deletion src/languages/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -438,10 +438,11 @@ export default {
or: ', or',
signInHere: 'just sign in here',
expiredCodeTitle: 'Magic code expired',
expiredCodeDescription: 'Go back to the original device and request a new code.',
expiredCodeDescription: 'Go back to the original device and request a new code',
successfulNewCodeRequest: 'Code requested. Please check your device.',
tfaRequiredTitle: 'Two-factor authentication\nrequired',
tfaRequiredDescription: "Please enter the two-factor authentication code\nwhere you're trying to sign in.",
requestOneHere: 'request one here.',
},
moneyRequestConfirmationList: {
paidBy: 'Paid by',
Expand Down
3 changes: 2 additions & 1 deletion src/languages/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -429,10 +429,11 @@ export default {
description: 'Por favor, introduce el código utilizando el dispositivo\nen el que se solicitó originalmente',
signInHere: 'simplemente inicia sesión aquí',
expiredCodeTitle: 'Código mágico caducado',
expiredCodeDescription: 'Vuelve al dispositivo original y solicita un código nuevo.',
expiredCodeDescription: 'Vuelve al dispositivo original y solicita un código nuevo',
successfulNewCodeRequest: 'Código solicitado. Por favor, comprueba tu dispositivo.',
tfaRequiredTitle: 'Se requiere autenticación\nde dos factores',
tfaRequiredDescription: 'Por favor, introduce el código de autenticación de dos factores\ndonde estás intentando iniciar sesión.',
requestOneHere: 'solicite uno aquí.',
},
moneyRequestConfirmationList: {
paidBy: 'Pagado por',
Expand Down
5 changes: 3 additions & 2 deletions src/pages/signin/ValidateCodeForm/BaseValidateCodeForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ function BaseValidateCodeForm({account, credentials, session, autoComplete, isUs
const [formError, setFormError] = useState<FormError>({});
const [validateCode, setValidateCode] = useState(credentials?.validateCode ?? '');
const [twoFactorAuthCode, setTwoFactorAuthCode] = useState('');
const [timeRemaining, setTimeRemaining] = useState(30);
const [timeRemaining, setTimeRemaining] = useState(CONST.REQUEST_CODE_DELAY as number);
const [recoveryCode, setRecoveryCode] = useState('');
const [needToClearError, setNeedToClearError] = useState<boolean>(!!account?.errors);

Expand All @@ -91,6 +91,7 @@ function BaseValidateCodeForm({account, credentials, session, autoComplete, isUs
if (!inputValidateCodeRef.current || !canFocusInputOnScreenFocus() || !isVisible || !isFocused) {
return;
}
setTimeRemaining(CONST.REQUEST_CODE_DELAY);
inputValidateCodeRef.current.focus();
}, [isVisible, isFocused]);

Expand Down Expand Up @@ -161,7 +162,7 @@ function BaseValidateCodeForm({account, credentials, session, autoComplete, isUs
User.resendValidateCode(credentials?.login ?? '');
inputValidateCodeRef.current?.clear();
// Give feedback to the user to let them know the email was sent so that they don't spam the button.
setTimeRemaining(30);
setTimeRemaining(CONST.REQUEST_CODE_DELAY);
};

/**
Expand Down
Loading