mirror of
https://github.com/bitsocialnet/5chan.git
synced 2026-08-03 07:41:04 +02:00
fix captchamodal loading of captcha img
This commit is contained in:
@@ -20,6 +20,7 @@ const CaptchaModal = () => {
|
|||||||
} = useGeneralStore(state => state);
|
} = useGeneralStore(state => state);
|
||||||
|
|
||||||
const [imageSources, setImageSources] = useState([]);
|
const [imageSources, setImageSources] = useState([]);
|
||||||
|
const [isLoading, setIsLoading] = useState(true);
|
||||||
const [currentChallengeIndex, setCurrentChallengeIndex] = useState(0);
|
const [currentChallengeIndex, setCurrentChallengeIndex] = useState(0);
|
||||||
const [totalChallenges, setTotalChallenges] = useState(0);
|
const [totalChallenges, setTotalChallenges] = useState(0);
|
||||||
const [isMobile, setIsMobile] = useState(window.innerWidth <= 480);
|
const [isMobile, setIsMobile] = useState(window.innerWidth <= 480);
|
||||||
@@ -49,7 +50,8 @@ const CaptchaModal = () => {
|
|||||||
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (challengesArray) {
|
if (isCaptchaOpen && challengesArray) {
|
||||||
|
setIsLoading(true);
|
||||||
const challenges = challengesArray.challenges;
|
const challenges = challengesArray.challenges;
|
||||||
const decryptedChallenges = [];
|
const decryptedChallenges = [];
|
||||||
|
|
||||||
@@ -61,8 +63,9 @@ const CaptchaModal = () => {
|
|||||||
|
|
||||||
setImageSources(decryptedChallenges);
|
setImageSources(decryptedChallenges);
|
||||||
setTotalChallenges(decryptedChallenges.length);
|
setTotalChallenges(decryptedChallenges.length);
|
||||||
|
setIsLoading(false);
|
||||||
}
|
}
|
||||||
}, [challengesArray]);
|
}, [challengesArray, isCaptchaOpen]);
|
||||||
|
|
||||||
|
|
||||||
const handleKeyDown = (event) => {
|
const handleKeyDown = (event) => {
|
||||||
@@ -157,7 +160,11 @@ const CaptchaModal = () => {
|
|||||||
ref={responseRef}
|
ref={responseRef}
|
||||||
onKeyDown={handleKeyDown}
|
onKeyDown={handleKeyDown}
|
||||||
autoFocus />
|
autoFocus />
|
||||||
<img src={imageSources[currentChallengeIndex]} alt="captcha" />
|
{isLoading ? (
|
||||||
|
<img src="" alt="loading..." style={{ visibility: "hidden" }} />
|
||||||
|
) : (
|
||||||
|
imageSources[currentChallengeIndex] && <img src={imageSources[currentChallengeIndex]} alt="captcha" />
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<span style={{lineHeight: '1.7'}}>
|
<span style={{lineHeight: '1.7'}}>
|
||||||
|
|||||||
@@ -58,6 +58,7 @@ export const StyledModal = styled(Modal)`
|
|||||||
position: relative;
|
position: relative;
|
||||||
clear: both;
|
clear: both;
|
||||||
width: 302px;
|
width: 302px;
|
||||||
|
height: 100px;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
margin-bottom: 3px;
|
margin-bottom: 3px;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user