diff --git a/src/pages/settings/Profile/Contacts/ValidateCodeForm/BaseValidateCodeForm.tsx b/src/pages/settings/Profile/Contacts/ValidateCodeForm/BaseValidateCodeForm.tsx index 352260c275f0..556d341d049f 100644 --- a/src/pages/settings/Profile/Contacts/ValidateCodeForm/BaseValidateCodeForm.tsx +++ b/src/pages/settings/Profile/Contacts/ValidateCodeForm/BaseValidateCodeForm.tsx @@ -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(null); - const isInitialCodeSent = useRef(false); useImperativeHandle(innerRef, () => ({ focus() { @@ -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; @@ -145,7 +134,6 @@ function BaseValidateCodeForm({account = {}, contactMethod, hasMagicCodeBeenSent const resendValidateCode = () => { User.requestContactMethodValidateCode(contactMethod); inputValidateCodeRef.current?.clear(); - isInitialCodeSent.current = false; }; /** @@ -213,7 +201,7 @@ function BaseValidateCodeForm({account = {}, contactMethod, hasMagicCodeBeenSent > {translate('validateCodeForm.magicCodeNotReceived')} - {hasMagicCodeBeenSent && !isInitialCodeSent.current && ( + {hasMagicCodeBeenSent && (