Update CaptchaModal.jsx

This commit is contained in:
plebeius.eth
2023-09-16 17:07:31 +02:00
parent 4c5198f40e
commit 6f2e8dcaa8
+7 -3
View File
@@ -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,13 +87,11 @@ const CaptchaModal = () => {
};
let isPromiseResolved = false;
const submitCaptcha = (callback) => {
if (!isPromiseResolved) {
setCaptchaResponse(responseRef.current.value);
resolveCaptchaPromise(responseRef.current.value);
isPromiseResolved = true;
setIsPromiseResolved(true);
}
setImageSources([]);
@@ -104,6 +103,11 @@ const CaptchaModal = () => {
}
};
useEffect(() => {
if (!isCaptchaOpen) {
setIsPromiseResolved(false);
}
}, [isCaptchaOpen]);
const handleCloseModal = () => {
setImageSources([]);