mirror of
https://github.com/bitsocialnet/5chan.git
synced 2026-08-03 07:41:04 +02:00
update posting logic
This commit is contained in:
@@ -0,0 +1,3 @@
|
|||||||
|
REACT_APP_PLEBBIT_REACT_HOOKS_MOCK_CONTENT=1
|
||||||
|
REACT_APP_PLEBBIT_REACT_HOOKS_MOCK_CONTENT_LOADING_TIME=1000
|
||||||
|
REACT_APP_PLEBBIT_REACT_HOOKS_MOCK_CONTENT_DOUBLE_MEDIA=1
|
||||||
@@ -62,9 +62,9 @@ const CaptchaModal = () => {
|
|||||||
<button className="icon" onClick={() => setIsCaptchaOpen(false)} title="close" />
|
<button className="icon" onClick={() => setIsCaptchaOpen(false)} title="close" />
|
||||||
</div>
|
</div>
|
||||||
<div id="form">
|
<div id="form">
|
||||||
{pendingComment.displayName ? (
|
{pendingComment.author?.displayName ? (
|
||||||
<div>
|
<div>
|
||||||
<input id="field" type="text" placeholder={pendingComment.displayName} disabled />
|
<input id="field" type="text" placeholder={pendingComment.author?.displayName} disabled />
|
||||||
</div>
|
</div>
|
||||||
) : null}
|
) : null}
|
||||||
{pendingComment.title ? (
|
{pendingComment.title ? (
|
||||||
|
|||||||
@@ -111,7 +111,9 @@ const ReplyModal = ({ isOpen, closeModal }) => {
|
|||||||
|
|
||||||
setPublishCommentOptions((prevPublishCommentOptions) => ({
|
setPublishCommentOptions((prevPublishCommentOptions) => ({
|
||||||
...prevPublishCommentOptions,
|
...prevPublishCommentOptions,
|
||||||
displayName: nameRef.current.value || undefined,
|
author: {
|
||||||
|
displayName: nameRef.current.value || undefined,
|
||||||
|
},
|
||||||
content: commentRef.current.value || undefined,
|
content: commentRef.current.value || undefined,
|
||||||
link: linkRef.current.value || undefined,
|
link: linkRef.current.value || undefined,
|
||||||
parentCid: selectedParentCid,
|
parentCid: selectedParentCid,
|
||||||
|
|||||||
@@ -98,7 +98,6 @@ const Board = () => {
|
|||||||
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});
|
||||||
console.log("challenge success", challengeVerification.publication?.cid, challengeVerification)
|
|
||||||
navigate(`/p/${selectedAddress}/c/${challengeVerification.publication?.cid}`);
|
navigate(`/p/${selectedAddress}/c/${challengeVerification.publication?.cid}`);
|
||||||
}
|
}
|
||||||
else if (challengeVerification.challengeSuccess === false) {
|
else if (challengeVerification.challengeSuccess === false) {
|
||||||
@@ -158,7 +157,9 @@ const Board = () => {
|
|||||||
|
|
||||||
setPublishCommentOptions((prevPublishCommentOptions) => ({
|
setPublishCommentOptions((prevPublishCommentOptions) => ({
|
||||||
...prevPublishCommentOptions,
|
...prevPublishCommentOptions,
|
||||||
displayName: nameRef.current.value || undefined,
|
author: {
|
||||||
|
displayName: nameRef.current.value || undefined,
|
||||||
|
},
|
||||||
title: subjectRef.current.value || undefined,
|
title: subjectRef.current.value || undefined,
|
||||||
content: commentRef.current.value || undefined,
|
content: commentRef.current.value || undefined,
|
||||||
link: linkRef.current.value || undefined,
|
link: linkRef.current.value || undefined,
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ import useSuccess from '../../hooks/useSuccess';
|
|||||||
|
|
||||||
const Catalog = () => {
|
const Catalog = () => {
|
||||||
const {
|
const {
|
||||||
captchaResponse, setCaptchaResponse,
|
setCaptchaResponse,
|
||||||
setChallengesArray,
|
setChallengesArray,
|
||||||
defaultSubplebbits,
|
defaultSubplebbits,
|
||||||
setIsCaptchaOpen,
|
setIsCaptchaOpen,
|
||||||
@@ -38,8 +38,6 @@ const Catalog = () => {
|
|||||||
const commentRef = useRef();
|
const commentRef = useRef();
|
||||||
const linkRef = useRef();
|
const linkRef = useRef();
|
||||||
|
|
||||||
const onChallengeVerificationRef = useRef();
|
|
||||||
|
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const [prevScrollPos, setPrevScrollPos] = useState(0);
|
const [prevScrollPos, setPrevScrollPos] = useState(0);
|
||||||
const [visible, setVisible] = useState(true);
|
const [visible, setVisible] = useState(true);
|
||||||
@@ -84,10 +82,12 @@ const Catalog = () => {
|
|||||||
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});
|
||||||
|
console.log("challenge success", challengeVerification.publication?.cid, challengeVerification)
|
||||||
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});
|
||||||
|
console.log("challenge failed", challengeVerification.reason, 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.");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -112,7 +112,7 @@ const Catalog = () => {
|
|||||||
const [publishCommentOptions, setPublishCommentOptions] = useState({
|
const [publishCommentOptions, setPublishCommentOptions] = useState({
|
||||||
subplebbitAddress: selectedAddress,
|
subplebbitAddress: selectedAddress,
|
||||||
onChallenge,
|
onChallenge,
|
||||||
onChallengeVerification: onChallengeVerificationRef.current,
|
onChallengeVerification,
|
||||||
onError: (error) => {
|
onError: (error) => {
|
||||||
setErrorMessage(error);
|
setErrorMessage(error);
|
||||||
},
|
},
|
||||||
@@ -129,9 +129,6 @@ const Catalog = () => {
|
|||||||
}, [index]);
|
}, [index]);
|
||||||
|
|
||||||
|
|
||||||
onChallengeVerificationRef.current = onChallengeVerification;
|
|
||||||
|
|
||||||
|
|
||||||
const resetFields = () => {
|
const resetFields = () => {
|
||||||
nameRef.current.value = '';
|
nameRef.current.value = '';
|
||||||
subjectRef.current.value = '';
|
subjectRef.current.value = '';
|
||||||
@@ -140,21 +137,14 @@ const Catalog = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
setPublishCommentOptions((prevPublishCommentOptions) => ({
|
|
||||||
...prevPublishCommentOptions,
|
|
||||||
subplebbitAddress: selectedAddress,
|
|
||||||
onChallengeVerification: onChallengeVerificationRef.current,
|
|
||||||
}));
|
|
||||||
}, [selectedAddress]);
|
|
||||||
|
|
||||||
|
|
||||||
const handleSubmit = async (event) => {
|
const handleSubmit = async (event) => {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
|
|
||||||
setPublishCommentOptions((prevPublishCommentOptions) => ({
|
setPublishCommentOptions((prevPublishCommentOptions) => ({
|
||||||
...prevPublishCommentOptions,
|
...prevPublishCommentOptions,
|
||||||
displayName: nameRef.current.value || undefined,
|
author: {
|
||||||
|
displayName: nameRef.current.value || undefined,
|
||||||
|
},
|
||||||
title: subjectRef.current.value || undefined,
|
title: subjectRef.current.value || undefined,
|
||||||
content: commentRef.current.value || undefined,
|
content: commentRef.current.value || undefined,
|
||||||
link: linkRef.current.value || undefined,
|
link: linkRef.current.value || undefined,
|
||||||
@@ -184,9 +174,10 @@ const Catalog = () => {
|
|||||||
challengeImg.onload = () => {
|
challengeImg.onload = () => {
|
||||||
setIsCaptchaOpen(true);
|
setIsCaptchaOpen(true);
|
||||||
|
|
||||||
const handleKeyDown = (event) => {
|
const handleKeyDown = async (event) => {
|
||||||
if (event.key === 'Enter') {
|
if (event.key === 'Enter') {
|
||||||
resolve(captchaResponse);
|
const currentCaptchaResponse = useGeneralStore.getState().captchaResponse;
|
||||||
|
resolve(currentCaptchaResponse);
|
||||||
setIsCaptchaOpen(false);
|
setIsCaptchaOpen(false);
|
||||||
document.removeEventListener('keydown', handleKeyDown);
|
document.removeEventListener('keydown', handleKeyDown);
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
|
|||||||
@@ -223,18 +223,18 @@ const Pending = () => {
|
|||||||
</span>)
|
</span>)
|
||||||
: null}
|
: null}
|
||||||
|
|
||||||
{comment.displayName
|
{comment.author?.displayName
|
||||||
? comment.displayName.length > 20
|
? comment.author?.displayName.length > 20
|
||||||
? <>
|
? <>
|
||||||
<span key={`n-${"pending"}`} className="name"
|
<span key={`n-${"pending"}`} className="name"
|
||||||
data-tooltip-id="tooltip"
|
data-tooltip-id="tooltip"
|
||||||
data-tooltip-content={comment.displayName}
|
data-tooltip-content={comment.author?.displayName}
|
||||||
data-tooltip-place="top">
|
data-tooltip-place="top">
|
||||||
{comment.displayName.slice(0, 20) + " (...)"}
|
{comment.author?.displayName.slice(0, 20) + " (...)"}
|
||||||
</span>
|
</span>
|
||||||
</>
|
</>
|
||||||
: <span key={`n-${"pending"}`} className="name">
|
: <span key={`n-${"pending"}`} className="name">
|
||||||
{comment.displayName}</span>
|
{comment.author?.displayName}</span>
|
||||||
: <span key={`n-${"pending"}`} className="name">
|
: <span key={`n-${"pending"}`} className="name">
|
||||||
Anonymous</span>}
|
Anonymous</span>}
|
||||||
|
|
||||||
@@ -269,18 +269,18 @@ const Pending = () => {
|
|||||||
<div key={`mob-pi-${"pending"}`} className="post-info-mobile">
|
<div key={`mob-pi-${"pending"}`} className="post-info-mobile">
|
||||||
<button style={{ all: 'unset', cursor: 'pointer' }} key={`mob-pb-${"pending"}`} className="post-menu-button-mobile" onClick={() => {}}>...</button>
|
<button style={{ all: 'unset', cursor: 'pointer' }} key={`mob-pb-${"pending"}`} className="post-menu-button-mobile" onClick={() => {}}>...</button>
|
||||||
<span className="name-block-mobile">
|
<span className="name-block-mobile">
|
||||||
{comment.displayName
|
{comment.author?.displayName
|
||||||
? comment.displayName.length > 15
|
? comment.author?.displayName.length > 15
|
||||||
? <>
|
? <>
|
||||||
<span key={`mob-n-${"pending"}`} className="name-mobile"
|
<span key={`mob-n-${"pending"}`} className="name-mobile"
|
||||||
data-tooltip-id="tooltip"
|
data-tooltip-id="tooltip"
|
||||||
data-tooltip-content={comment.displayName}
|
data-tooltip-content={comment.author?.displayName}
|
||||||
data-tooltip-place="top">
|
data-tooltip-place="top">
|
||||||
{comment.displayName.slice(0, 15) + " (...)"}
|
{comment.author?.displayName.slice(0, 15) + " (...)"}
|
||||||
</span>
|
</span>
|
||||||
</>
|
</>
|
||||||
: <span key={`mob-n-${"pending"}`} className="name-mobile">
|
: <span key={`mob-n-${"pending"}`} className="name-mobile">
|
||||||
{comment.displayName}</span>
|
{comment.author?.displayName}</span>
|
||||||
: <span key={`mob-n-${"pending"}`} className="name-mobile">
|
: <span key={`mob-n-${"pending"}`} className="name-mobile">
|
||||||
Anonymous</span>}
|
Anonymous</span>}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user