mirror of
https://github.com/bitsocialnet/5chan.git
synced 2026-08-03 07:41:04 +02:00
Update CaptchaModal.jsx
This commit is contained in:
@@ -26,6 +26,7 @@ const CaptchaModal = () => {
|
|||||||
const [isMobile, setIsMobile] = useState(window.innerWidth <= 480);
|
const [isMobile, setIsMobile] = useState(window.innerWidth <= 480);
|
||||||
const responseRef = useRef();
|
const responseRef = useRef();
|
||||||
const nodeRef = useRef(null);
|
const nodeRef = useRef(null);
|
||||||
|
const [isPromiseResolved, setIsPromiseResolved] = useState(false);
|
||||||
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -86,13 +87,11 @@ const CaptchaModal = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
let isPromiseResolved = false;
|
|
||||||
|
|
||||||
const submitCaptcha = (callback) => {
|
const submitCaptcha = (callback) => {
|
||||||
if (!isPromiseResolved) {
|
if (!isPromiseResolved) {
|
||||||
setCaptchaResponse(responseRef.current.value);
|
setCaptchaResponse(responseRef.current.value);
|
||||||
resolveCaptchaPromise(responseRef.current.value);
|
resolveCaptchaPromise(responseRef.current.value);
|
||||||
isPromiseResolved = true;
|
setIsPromiseResolved(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
setImageSources([]);
|
setImageSources([]);
|
||||||
@@ -104,6 +103,11 @@ const CaptchaModal = () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (!isCaptchaOpen) {
|
||||||
|
setIsPromiseResolved(false);
|
||||||
|
}
|
||||||
|
}, [isCaptchaOpen]);
|
||||||
|
|
||||||
const handleCloseModal = () => {
|
const handleCloseModal = () => {
|
||||||
setImageSources([]);
|
setImageSources([]);
|
||||||
|
|||||||
Reference in New Issue
Block a user