mirror of
https://github.com/bitsocialnet/5chan.git
synced 2026-08-03 07:41:04 +02:00
added pending comment index
This commit is contained in:
@@ -96,23 +96,19 @@ const Board = () => {
|
||||
|
||||
const onChallengeVerification = (challengeVerification) => {
|
||||
if (challengeVerification.challengeSuccess === true) {
|
||||
setSuccessMessage('challenge success', {publishedCid: challengeVerification.publication?.cid});
|
||||
setSuccessMessage('Challenge success.', {publishedCid: 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('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) => {
|
||||
setPendingComment(comment);
|
||||
let challengeAnswers = [];
|
||||
navigate(`/p/${selectedAddress}/c/pending`)
|
||||
|
||||
try {
|
||||
challengeAnswers = await getChallengeAnswersFromUser(challenges)
|
||||
@@ -123,17 +119,9 @@ const Board = () => {
|
||||
if (challengeAnswers) {
|
||||
await comment.publishChallengeAnswers(challengeAnswers)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
const resetFields = () => {
|
||||
nameRef.current.value = '';
|
||||
subjectRef.current.value = '';
|
||||
commentRef.current.value = '';
|
||||
linkRef.current.value = '';
|
||||
};
|
||||
|
||||
|
||||
|
||||
const [publishCommentOptions, setPublishCommentOptions] = useState({
|
||||
subplebbitAddress: selectedAddress,
|
||||
onChallenge,
|
||||
@@ -143,6 +131,26 @@ const Board = () => {
|
||||
},
|
||||
});
|
||||
|
||||
const { publishComment, index } = usePublishComment(publishCommentOptions);
|
||||
|
||||
useEffect(() => {
|
||||
if (index !== undefined) {
|
||||
navigate(`/profile/c/${index}`);
|
||||
setSuccessMessage('Comment pending with index ' + index + '.');
|
||||
}
|
||||
}, [index]);
|
||||
|
||||
|
||||
onChallengeVerificationRef.current = onChallengeVerification;
|
||||
|
||||
|
||||
const resetFields = () => {
|
||||
nameRef.current.value = '';
|
||||
subjectRef.current.value = '';
|
||||
commentRef.current.value = '';
|
||||
linkRef.current.value = '';
|
||||
};
|
||||
|
||||
|
||||
useEffect(() => {
|
||||
setPublishCommentOptions((prevPublishCommentOptions) => ({
|
||||
@@ -174,9 +182,6 @@ const Board = () => {
|
||||
})();
|
||||
}
|
||||
}, [publishCommentOptions]);
|
||||
|
||||
|
||||
const { publishComment } = usePublishComment(publishCommentOptions);
|
||||
|
||||
|
||||
const getChallengeAnswersFromUser = async (challenges) => {
|
||||
|
||||
Reference in New Issue
Block a user