fix onChallengeVerification

This commit is contained in:
plebbitor
2023-04-11 18:12:11 +02:00
parent 47aa173e5e
commit b255311e30
+14 -3
View File
@@ -92,17 +92,20 @@ const Board = () => {
};
const onChallengeVerificationRef = useRef();
const onChallengeVerification = (challengeVerification) => {
if (challengeVerification.challengeSuccess === true) {
setSuccessMessage('challenge success', {publishedCid: challengeVerification.publication.cid});
setSelectedThread(challengeVerification.publication.cid);
navigate(`/p/${selectedAddress}/c/${challengeVerification.publication.cid}`);
}
else if (challengeVerification.challengeSuccess === false) {
setErrorMessage('challenge failed', {reason: challengeVerification.reason, errors: challengeVerification.errors});
setErrorMessage("Error: You seem to have mistyped the CAPTCHA. Please try again.");
}
}
};
onChallengeVerificationRef.current = onChallengeVerification;
const onChallenge = async (challenges, comment) => {
@@ -133,12 +136,20 @@ const Board = () => {
const [publishCommentOptions, setPublishCommentOptions] = useState({
subplebbitAddress: selectedAddress,
onChallenge,
onChallengeVerification,
onChallengeVerification: onChallengeVerificationRef.current,
onError: (error) => {
setErrorMessage(error);
},
});
useEffect(() => {
setPublishCommentOptions((prevPublishCommentOptions) => ({
...prevPublishCommentOptions,
subplebbitAddress: selectedAddress,
onChallengeVerification: onChallengeVerificationRef.current,
}));
}, [selectedAddress]);
const handleSubmit = async (event) => {
event.preventDefault();