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

Revert "Fix send validate code in Validation Form" #46846

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
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ function BaseValidateCodeForm({account = {}, contactMethod, hasMagicCodeBeenSent
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing -- nullish coalescing doesn't achieve the same result in this case
const shouldDisableResendValidateCode = !!isOffline || account?.isLoading;
const focusTimeoutRef = useRef<NodeJS.Timeout | null>(null);
const isInitialCodeSent = useRef<boolean>(false);

useImperativeHandle(innerRef, () => ({
focus() {
Expand Down Expand Up @@ -122,16 +121,6 @@ function BaseValidateCodeForm({account = {}, contactMethod, hasMagicCodeBeenSent
// eslint-disable-next-line react-compiler/react-compiler, react-hooks/exhaustive-deps
}, []);

// when user first time opens validate code form we need to trigger API to send a code.
// otherwise user will need to click on re-send code button
useEffect(() => {
if (isInitialCodeSent.current || hasMagicCodeBeenSent || (!hasMagicCodeBeenSent && loginData?.pendingFields?.validateCodeSent)) {
return;
}
isInitialCodeSent.current = true;
User.requestContactMethodValidateCode(contactMethod);
}, [contactMethod, hasMagicCodeBeenSent, loginData?.pendingFields?.validateCodeSent]);

useEffect(() => {
if (!hasMagicCodeBeenSent) {
return;
Expand All @@ -145,7 +134,6 @@ function BaseValidateCodeForm({account = {}, contactMethod, hasMagicCodeBeenSent
const resendValidateCode = () => {
User.requestContactMethodValidateCode(contactMethod);
inputValidateCodeRef.current?.clear();
isInitialCodeSent.current = false;
};

/**
Expand Down Expand Up @@ -213,7 +201,7 @@ function BaseValidateCodeForm({account = {}, contactMethod, hasMagicCodeBeenSent
>
<Text style={[StyleUtils.getDisabledLinkStyles(shouldDisableResendValidateCode)]}>{translate('validateCodeForm.magicCodeNotReceived')}</Text>
</PressableWithFeedback>
{hasMagicCodeBeenSent && !isInitialCodeSent.current && (
{hasMagicCodeBeenSent && (
<DotIndicatorMessage
type="success"
style={[styles.mt6, styles.flex0]}
Expand Down
Loading