From c5b7f67a22a31157ad0d8c57efca8ee37bfeaf71 Mon Sep 17 00:00:00 2001 From: plebbitor Date: Sun, 16 Apr 2023 18:07:20 +0200 Subject: [PATCH] added pending reply to thread --- src/components/views/Pending.jsx | 1 - src/components/views/Thread.jsx | 19 +++++++++++-------- src/utils/renderThreadComments.js | 18 ++++++++++++------ 3 files changed, 23 insertions(+), 15 deletions(-) diff --git a/src/components/views/Pending.jsx b/src/components/views/Pending.jsx index b766b9cc..4456f321 100644 --- a/src/components/views/Pending.jsx +++ b/src/components/views/Pending.jsx @@ -252,7 +252,6 @@ const Pending = () => {   {}} title="Link to this post">c/ -   Pending    diff --git a/src/components/views/Thread.jsx b/src/components/views/Thread.jsx index 098eedd0..17e2cb78 100644 --- a/src/components/views/Thread.jsx +++ b/src/components/views/Thread.jsx @@ -28,7 +28,7 @@ const Thread = () => { defaultSubplebbits, setIsCaptchaOpen, isSettingsOpen, setIsSettingsOpen, - setPendingComment, + pendingComment, setPendingComment, selectedAddress, setSelectedAddress, setSelectedParentCid, setSelectedShortCid, @@ -61,7 +61,7 @@ const Thread = () => { useError(errorMessage, [errorMessage]); useSuccess(successMessage, [successMessage]); - const renderedComments = renderThreadComments(comment?.replies?.pages?.topAll.comments); + const renderedComments = renderThreadComments(comment, pendingComment); // temporary title from JSON, gets subplebbitAddress and threadCid from URL useEffect(() => { @@ -90,7 +90,6 @@ const Thread = () => { const onChallengeVerification = (challengeVerification) => { if (challengeVerification.challengeSuccess === true) { setSuccessMessage('challenge success', {publishedCid: challengeVerification.publication?.cid}); - navigate(`/p/${selectedAddress}/c/${selectedThread}`); } else if (challengeVerification.challengeSuccess === false) { setErrorMessage('challenge failed', {reason: challengeVerification.reason, errors: challengeVerification.errors}); @@ -130,7 +129,7 @@ const Thread = () => { useEffect(() => { if (index !== undefined) { - navigate(`/profile/c/${index}`); + window.scrollTo(0, document.body.scrollHeight); setSuccessMessage('Comment pending with index ' + index + '.'); } }, [index]); @@ -160,7 +159,9 @@ const Thread = () => { setPublishCommentOptions((prevPublishCommentOptions) => ({ ...prevPublishCommentOptions, - displayName: nameRef.current.value || undefined, + author: { + displayName: nameRef.current.value || undefined, + }, content: commentRef.current.value || undefined, link: linkRef.current.value || undefined, parentCid: selectedThread, @@ -526,14 +527,14 @@ const Thread = () => { : - {reply.author?.displayName} + {reply.author?.displayName ?? reply.displayName} : Anonymous}   (u/ - {reply.author?.shortAddress} + {reply.author?.shortAddress ?? reply.author.address} ) @@ -544,7 +545,9 @@ const Thread = () => { {}} title="Link to this post">c/ + }} title="Reply to this post">{reply.shortCid ?? ( + Pending + )}