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) => {
|
||||
|
||||
@@ -51,7 +51,6 @@ const Catalog = () => {
|
||||
useError(errorMessage, [errorMessage]);
|
||||
useSuccess(successMessage, [successMessage]);
|
||||
|
||||
|
||||
// temporary title from JSON, gets subplebbitAddress from URL
|
||||
useEffect(() => {
|
||||
setSelectedAddress(subplebbitAddress);
|
||||
@@ -84,23 +83,19 @@ const Catalog = () => {
|
||||
|
||||
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)
|
||||
@@ -111,14 +106,6 @@ const Catalog = () => {
|
||||
if (challengeAnswers) {
|
||||
await comment.publishChallengeAnswers(challengeAnswers)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
const resetFields = () => {
|
||||
nameRef.current.value = '';
|
||||
subjectRef.current.value = '';
|
||||
commentRef.current.value = '';
|
||||
linkRef.current.value = '';
|
||||
};
|
||||
|
||||
|
||||
@@ -131,6 +118,28 @@ const Catalog = () => {
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
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) => ({
|
||||
...prevPublishCommentOptions,
|
||||
@@ -161,9 +170,6 @@ const Catalog = () => {
|
||||
})();
|
||||
}
|
||||
}, [publishCommentOptions]);
|
||||
|
||||
|
||||
const { publishComment } = usePublishComment(publishCommentOptions);
|
||||
|
||||
|
||||
const getChallengeAnswersFromUser = async (challenges) => {
|
||||
|
||||
@@ -37,7 +37,6 @@ const Pending = () => {
|
||||
const commentMediaInfo = getCommentMediaInfo(comment);
|
||||
const fallbackImgUrl = "/assets/filedeleted-res.gif";
|
||||
|
||||
|
||||
const [selectedAddress, setSelectedAddress] = useState(comment.subplebbitAddress);
|
||||
const [selectedTitle, setSelectedTitle] = useState(null);
|
||||
|
||||
@@ -119,8 +118,8 @@ const Pending = () => {
|
||||
<ImageBanner />
|
||||
</div>
|
||||
<>
|
||||
<div className="board-title">{selectedTitle}</div>
|
||||
<div className="board-address">p/{selectedAddress}</div>
|
||||
<div className="board-title">{selectedTitle ?? null}</div>
|
||||
<div className="board-address">{selectedAddress ? ("p/" + selectedAddress) : null}</div>
|
||||
</>
|
||||
</>
|
||||
</Header>
|
||||
|
||||
@@ -58,7 +58,6 @@ const Thread = () => {
|
||||
useError(errorMessage, [errorMessage]);
|
||||
useSuccess(successMessage, [successMessage]);
|
||||
|
||||
|
||||
// temporary title from JSON, gets subplebbitAddress and threadCid from URL
|
||||
useEffect(() => {
|
||||
setSelectedAddress(subplebbitAddress);
|
||||
@@ -95,13 +94,9 @@ const Thread = () => {
|
||||
};
|
||||
|
||||
|
||||
onChallengeVerificationRef.current = onChallengeVerification;
|
||||
|
||||
|
||||
const onChallenge = async (challenges, comment) => {
|
||||
setPendingComment(comment);
|
||||
let challengeAnswers = [];
|
||||
navigate(`/p/${selectedAddress}/c/pending`)
|
||||
|
||||
try {
|
||||
challengeAnswers = await getChallengeAnswersFromUser(challenges)
|
||||
@@ -112,13 +107,6 @@ const Thread = () => {
|
||||
if (challengeAnswers) {
|
||||
await comment.publishChallengeAnswers(challengeAnswers)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
const resetFields = () => {
|
||||
nameRef.current.value = '';
|
||||
commentRef.current.value = '';
|
||||
linkRef.current.value = '';
|
||||
};
|
||||
|
||||
|
||||
@@ -132,6 +120,27 @@ const Thread = () => {
|
||||
});
|
||||
|
||||
|
||||
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 = '';
|
||||
commentRef.current.value = '';
|
||||
linkRef.current.value = '';
|
||||
};
|
||||
|
||||
|
||||
useEffect(() => {
|
||||
setPublishCommentOptions((prevPublishCommentOptions) => ({
|
||||
...prevPublishCommentOptions,
|
||||
@@ -163,9 +172,6 @@ const Thread = () => {
|
||||
}, [publishCommentOptions]);
|
||||
|
||||
|
||||
const { publishComment } = usePublishComment(publishCommentOptions);
|
||||
|
||||
|
||||
const getChallengeAnswersFromUser = async (challenges) => {
|
||||
setChallengesArray(challenges);
|
||||
|
||||
@@ -206,7 +212,6 @@ const Thread = () => {
|
||||
navigate(`/p/${selected}`);
|
||||
};
|
||||
|
||||
|
||||
// scroll to post when quote is clicked
|
||||
function handleQuoteClick(reply, event) {
|
||||
event.preventDefault();
|
||||
|
||||
Reference in New Issue
Block a user