From 43f63aa341d2f861087a7c4ed95dd04bf9674d44 Mon Sep 17 00:00:00 2001 From: "plebeius.eth" Date: Sat, 16 Sep 2023 21:10:38 +0200 Subject: [PATCH] update mod edit --- src/components/views/All.jsx | 1 - src/components/views/Board.jsx | 1 - src/components/views/Subscriptions.jsx | 1 - src/components/views/Thread.jsx | 29 ++++++++++++++++++++++++-- 4 files changed, 27 insertions(+), 5 deletions(-) diff --git a/src/components/views/All.jsx b/src/components/views/All.jsx index 23d4a236..13ef8e2b 100755 --- a/src/components/views/All.jsx +++ b/src/components/views/All.jsx @@ -721,7 +721,6 @@ const All = () => { if (thread.removed) { thread.content = "[removed]"; thread.link = undefined; - thread.title = "[removed]"; } }; const { displayedReplies, omittedCount } = filteredRepliesByThread[thread.cid] || {}; diff --git a/src/components/views/Board.jsx b/src/components/views/Board.jsx index 183e78f3..c6cde796 100755 --- a/src/components/views/Board.jsx +++ b/src/components/views/Board.jsx @@ -1636,7 +1636,6 @@ const Board = () => { if (thread.removed) { thread.content = "[removed]"; thread.link = undefined; - thread.title = "[removed]"; } }; const { displayedReplies, omittedCount } = filteredRepliesByThread[thread.cid] || {}; diff --git a/src/components/views/Subscriptions.jsx b/src/components/views/Subscriptions.jsx index 9beb6009..eaab82e5 100755 --- a/src/components/views/Subscriptions.jsx +++ b/src/components/views/Subscriptions.jsx @@ -729,7 +729,6 @@ const Subscriptions = () => { if (thread.removed) { thread.content = "[removed]"; thread.link = undefined; - thread.title = "[removed]"; } }; const { displayedReplies, omittedCount } = filteredRepliesByThread[thread.cid] || {}; diff --git a/src/components/views/Thread.jsx b/src/components/views/Thread.jsx index 5204cda9..4c805107 100755 --- a/src/components/views/Thread.jsx +++ b/src/components/views/Thread.jsx @@ -56,6 +56,7 @@ const Thread = () => { setChallengesArray, defaultSubplebbits, editedComment, + editedComments, setIsAuthorDelete, setIsAuthorEdit, setIsCaptchaOpen, @@ -134,9 +135,10 @@ const Thread = () => { useAnonMode(selectedThread, anonymousMode && executeAnonMode); - const comment = useComment({commentCid: selectedThread}); + const originalComment = useComment({commentCid: selectedThread}); + const [comment, setComment] = useState(originalComment); const { subplebbitAddress, threadCid } = useParams(); - const subplebbit = useSubplebbit({subplebbitAddress: comment.subplebbitAddress}); + const subplebbit = useSubplebbit({subplebbitAddress: originalComment.subplebbitAddress}); const selectedAddress = subplebbit.address; const stateString = useStateString(comment); @@ -144,6 +146,22 @@ const Thread = () => { const commentMediaInfo = getCommentMediaInfo(comment); const fallbackImgUrl = "assets/filedeleted-res.gif"; + + useEffect(() => { + let updatedComment = { ...originalComment }; + + if (editedComments[originalComment.cid]) { + updatedComment = { ...originalComment, ...editedComments[originalComment.cid] }; + + if (updatedComment.removed) { + updatedComment.content = "[removed]"; + updatedComment.link = undefined; + } + } + + setComment(updatedComment); + }, [originalComment, editedComments]); + const handleThumbnailClick = (index, type) => { switch(type) { @@ -1272,6 +1290,13 @@ const Thread = () => { {comment.replyCount === undefined ? : null} {sortedReplies.map((reply, index) => { + if (editedComments[reply.cid]) { + reply = editedComments[reply.cid]; + if (reply.removed) { + reply.content = "[removed]"; + reply.link = undefined; + } + } const replyMediaInfo = getCommentMediaInfo(reply); const fallbackImgUrl = "assets/filedeleted-res.gif"; const shortParentCid = findShortParentCid(reply.parentCid, comment);