From b0708dcefbc005cf26bd4208a0a09bea2e83285e Mon Sep 17 00:00:00 2001 From: Samuel Newman Date: Fri, 29 May 2026 21:03:00 +0300 Subject: [PATCH] Fix email verification dialog (#10657) --- eslint-suppressions.json | 5 -- .../components/ResendEmailText.tsx | 10 ++-- .../EmailDialog/components/TokenField.tsx | 7 ++- src/components/dialogs/EmailDialog/index.tsx | 8 ++-- .../EmailDialog/screens/Manage2FA/Disable.tsx | 19 ++++---- .../EmailDialog/screens/Manage2FA/Enable.tsx | 14 ++---- .../dialogs/EmailDialog/screens/Update.tsx | 23 ++++------ .../screens/VerificationReminder.tsx | 16 ++----- .../dialogs/EmailDialog/screens/Verify.tsx | 46 ++++++++++--------- 9 files changed, 62 insertions(+), 86 deletions(-) diff --git a/eslint-suppressions.json b/eslint-suppressions.json index ce02698ce6..2bbe927a12 100644 --- a/eslint-suppressions.json +++ b/eslint-suppressions.json @@ -124,11 +124,6 @@ "count": 1 } }, - "src/components/dialogs/EmailDialog/components/ResendEmailText.tsx": { - "@typescript-eslint/no-explicit-any": { - "count": 1 - } - }, "src/components/dialogs/LanguageSelectDialog.tsx": { "@typescript-eslint/no-explicit-any": { "count": 1 diff --git a/src/components/dialogs/EmailDialog/components/ResendEmailText.tsx b/src/components/dialogs/EmailDialog/components/ResendEmailText.tsx index 85f0b8a60a..300feeefae 100644 --- a/src/components/dialogs/EmailDialog/components/ResendEmailText.tsx +++ b/src/components/dialogs/EmailDialog/components/ResendEmailText.tsx @@ -1,7 +1,5 @@ import {useState} from 'react' -import {msg} from '@lingui/core/macro' -import {useLingui} from '@lingui/react' -import {Trans} from '@lingui/react/macro' +import {Trans, useLingui} from '@lingui/react/macro' import {wait} from '#/lib/async/wait' import {atoms as a, type TextStyleProp, useTheme} from '#/alf' @@ -14,10 +12,10 @@ export function ResendEmailText({ onPress, style, }: TextStyleProp & { - onPress: () => Promise + onPress: () => Promise }) { const t = useTheme() - const {_} = useLingui() + const {t: l} = useLingui() const [status, setStatus] = useState<'sending' | 'success' | null>(null) const handleOnPress = async () => { @@ -38,7 +36,7 @@ export function ResendEmailText({ Don't see an email?{' '} { handleOnPress() })}> diff --git a/src/components/dialogs/EmailDialog/components/TokenField.tsx b/src/components/dialogs/EmailDialog/components/TokenField.tsx index 04a55a26de..1e37278bdf 100644 --- a/src/components/dialogs/EmailDialog/components/TokenField.tsx +++ b/src/components/dialogs/EmailDialog/components/TokenField.tsx @@ -1,6 +1,5 @@ import {type TextInputProps, View} from 'react-native' -import {msg} from '@lingui/core/macro' -import {useLingui} from '@lingui/react' +import {useLingui} from '@lingui/react/macro' import * as TextField from '#/components/forms/TextField' import {Shield_Stroke2_Corner0_Rounded as Shield} from '#/components/icons/Shield' @@ -20,7 +19,7 @@ export function TokenField({ onChangeText, onSubmitEditing, }: Pick) { - const {_} = useLingui() + const {t: l} = useLingui() const isInvalid = Boolean(value && value.length > 10 && !isValidCode(value)) const handleOnChangeText = (v: string) => { @@ -35,7 +34,7 @@ export function TokenField({ autoComplete="off" autoCorrect={false} isInvalid={isInvalid} - label={_(msg`Confirmation code`)} + label={l`Confirmation code`} maxLength={11} placeholder="XXXXX-XXXXX" value={value} diff --git a/src/components/dialogs/EmailDialog/index.tsx b/src/components/dialogs/EmailDialog/index.tsx index 729557146c..87ddab37b6 100644 --- a/src/components/dialogs/EmailDialog/index.tsx +++ b/src/components/dialogs/EmailDialog/index.tsx @@ -1,6 +1,5 @@ import {useCallback, useState} from 'react' -import {msg} from '@lingui/core/macro' -import {useLingui} from '@lingui/react' +import {useLingui} from '@lingui/react/macro' import {web} from '#/alf' import * as Dialog from '#/components/Dialog' @@ -21,7 +20,7 @@ export function useEmailDialogControl() { } export function EmailDialog() { - const {_} = useLingui() + const {t: l} = useLingui() const emailDialogControl = useEmailDialogControl() const {isEmailVerified} = useAccountEmailState() const onClose = useCallback(() => { @@ -36,9 +35,8 @@ export function EmailDialog() { return ( - diff --git a/src/components/dialogs/EmailDialog/screens/Manage2FA/Disable.tsx b/src/components/dialogs/EmailDialog/screens/Manage2FA/Disable.tsx index 45627f5c88..2fa94c8bf7 100644 --- a/src/components/dialogs/EmailDialog/screens/Manage2FA/Disable.tsx +++ b/src/components/dialogs/EmailDialog/screens/Manage2FA/Disable.tsx @@ -1,8 +1,6 @@ import {useReducer, useState} from 'react' import {View} from 'react-native' -import {msg} from '@lingui/core/macro' -import {useLingui} from '@lingui/react' -import {Trans} from '@lingui/react/macro' +import {Trans, useLingui} from '@lingui/react/macro' import {wait} from '#/lib/async/wait' import {useCleanError} from '#/lib/hooks/useCleanError' @@ -90,7 +88,7 @@ function reducer(state: State, action: Action): State { export function Disable() { const t = useTheme() - const {_} = useLingui() + const {t: l} = useLingui() const cleanError = useCleanError() const {currentAccount} = useSession() const {mutateAsync: requestEmailUpdate} = useRequestEmailUpdate() @@ -120,7 +118,7 @@ export function Disable() { const {clean} = cleanError(e) dispatch({ type: 'setError', - error: clean || _(msg`Failed to send email, please try again.`), + error: clean || l`Failed to send email, please try again.`, }) } } @@ -129,7 +127,7 @@ export function Disable() { if (!isValidCode(token)) { dispatch({ type: 'setError', - error: _(msg`Please enter a valid code.`), + error: l`Please enter a valid code.`, }) return } @@ -147,7 +145,7 @@ export function Disable() { const {clean} = cleanError(e) dispatch({ type: 'setError', - error: clean || _(msg`Failed to update email 2FA settings`), + error: clean || l`Failed to update email 2FA settings`, }) } } @@ -157,7 +155,6 @@ export function Disable() { Disable email 2FA - {state.step === 'email' ? ( <> {state.error}} ) } @@ -273,7 +282,7 @@ export function Verify({config, showScreen}: ScreenProps) { If you need to update your email,{' '} { showScreen({id: ScreenID.Update}) })}> @@ -288,12 +297,11 @@ export function Verify({config, showScreen}: ScreenProps) { )} - {state.step === 'email' && state.mutationStatus !== 'success' ? ( <> {state.error && {state.error}} ) : null} - {state.step === 'email' && ( <> @@ -318,7 +325,7 @@ export function Verify({config, showScreen}: ScreenProps) { Have a code?{' '} { dispatch({ type: 'setStep', @@ -331,7 +338,6 @@ export function Verify({config, showScreen}: ScreenProps) { )} - {state.step === 'token' ? ( <> ) { {state.error && {state.error}}