mirror of
https://github.com/bitsocialnet/5chan.git
synced 2026-08-03 07:41:04 +02:00
fix onChallengeVerification
This commit is contained in:
@@ -92,17 +92,20 @@ const Board = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
const onChallengeVerificationRef = useRef();
|
||||||
|
|
||||||
const onChallengeVerification = (challengeVerification) => {
|
const onChallengeVerification = (challengeVerification) => {
|
||||||
if (challengeVerification.challengeSuccess === true) {
|
if (challengeVerification.challengeSuccess === true) {
|
||||||
setSuccessMessage('challenge success', {publishedCid: challengeVerification.publication.cid});
|
setSuccessMessage('challenge success', {publishedCid: challengeVerification.publication.cid});
|
||||||
setSelectedThread(challengeVerification.publication.cid);
|
|
||||||
navigate(`/p/${selectedAddress}/c/${challengeVerification.publication.cid}`);
|
navigate(`/p/${selectedAddress}/c/${challengeVerification.publication.cid}`);
|
||||||
}
|
}
|
||||||
else if (challengeVerification.challengeSuccess === false) {
|
else if (challengeVerification.challengeSuccess === false) {
|
||||||
setErrorMessage('challenge failed', {reason: challengeVerification.reason, errors: challengeVerification.errors});
|
setErrorMessage('challenge failed', {reason: challengeVerification.reason, errors: challengeVerification.errors});
|
||||||
setErrorMessage("Error: You seem to have mistyped the CAPTCHA. Please try again.");
|
setErrorMessage("Error: You seem to have mistyped the CAPTCHA. Please try again.");
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
|
onChallengeVerificationRef.current = onChallengeVerification;
|
||||||
|
|
||||||
|
|
||||||
const onChallenge = async (challenges, comment) => {
|
const onChallenge = async (challenges, comment) => {
|
||||||
@@ -133,12 +136,20 @@ const Board = () => {
|
|||||||
const [publishCommentOptions, setPublishCommentOptions] = useState({
|
const [publishCommentOptions, setPublishCommentOptions] = useState({
|
||||||
subplebbitAddress: selectedAddress,
|
subplebbitAddress: selectedAddress,
|
||||||
onChallenge,
|
onChallenge,
|
||||||
onChallengeVerification,
|
onChallengeVerification: onChallengeVerificationRef.current,
|
||||||
onError: (error) => {
|
onError: (error) => {
|
||||||
setErrorMessage(error);
|
setErrorMessage(error);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
setPublishCommentOptions((prevPublishCommentOptions) => ({
|
||||||
|
...prevPublishCommentOptions,
|
||||||
|
subplebbitAddress: selectedAddress,
|
||||||
|
onChallengeVerification: onChallengeVerificationRef.current,
|
||||||
|
}));
|
||||||
|
}, [selectedAddress]);
|
||||||
|
|
||||||
|
|
||||||
const handleSubmit = async (event) => {
|
const handleSubmit = async (event) => {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
|
|||||||
Reference in New Issue
Block a user