From 6f2e8dcaa871187d0dcb4cd23fc847d2de7c7440 Mon Sep 17 00:00:00 2001 From: "plebeius.eth" Date: Sat, 16 Sep 2023 17:07:31 +0200 Subject: [PATCH] Update CaptchaModal.jsx --- src/components/modals/CaptchaModal.jsx | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/components/modals/CaptchaModal.jsx b/src/components/modals/CaptchaModal.jsx index a654b69f..3abd06e4 100644 --- a/src/components/modals/CaptchaModal.jsx +++ b/src/components/modals/CaptchaModal.jsx @@ -26,6 +26,7 @@ const CaptchaModal = () => { const [isMobile, setIsMobile] = useState(window.innerWidth <= 480); const responseRef = useRef(); const nodeRef = useRef(null); + const [isPromiseResolved, setIsPromiseResolved] = useState(false); useEffect(() => { @@ -86,24 +87,27 @@ const CaptchaModal = () => { }; - let isPromiseResolved = false; - const submitCaptcha = (callback) => { if (!isPromiseResolved) { setCaptchaResponse(responseRef.current.value); resolveCaptchaPromise(responseRef.current.value); - isPromiseResolved = true; + setIsPromiseResolved(true); } setImageSources([]); setChallengesArray([]); setIsCaptchaOpen(false); - + if (callback) { callback(responseRef.current.value); } }; + useEffect(() => { + if (!isCaptchaOpen) { + setIsPromiseResolved(false); + } + }, [isCaptchaOpen]); const handleCloseModal = () => { setImageSources([]);