-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
refactor(deposit): send email throws true method #17034
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
Conversation
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: Loading State Timing and Error Persistence Issues
The isLoading state is set prematurely before email validation, causing a brief, incorrect loading state when an invalid email is entered and no API call is made. Additionally, API errors are not cleared on subsequent submission attempts if the input text remains unchanged, leading to stale error messages persisting during the loading state.
app/components/UI/Ramp/Deposit/Views/EnterEmail/EnterEmail.tsx#L80-L103
metamask-mobile/app/components/UI/Ramp/Deposit/Views/EnterEmail/EnterEmail.tsx
Lines 80 to 103 in aed1bac
| const handleSubmit = useCallback(async () => { | |
| try { | |
| setIsLoading(true); | |
| if (validateEmail(email)) { | |
| setValidationError(false); | |
| await submitEmail(); | |
| navigation.navigate( | |
| ...createOtpCodeNavDetails({ | |
| quote, | |
| email, | |
| paymentMethodId, | |
| cryptoCurrencyChainId, | |
| }), | |
| ); | |
| } else { | |
| setValidationError(true); | |
| } | |
| } catch (e) { | |
| setError(strings('deposit.enter_email.error')); | |
| Logger.error(e as Error, 'Error submitting email'); | |
| } finally { | |
| setIsLoading(false); | |
| } |
Was this report helpful? Give feedback by reacting with 👍 or 👎



Description
This PR refactors the send email method into the new promise style method call.
Changelog
CHANGELOG entry:
Related issues
Fixes:
Manual testing steps
Screenshots/Recordings
Before
After
Pre-merge author checklist
Pre-merge reviewer checklist