From e636258f0f04f6084a8278a57a190dfc17bb1451 Mon Sep 17 00:00:00 2001 From: plebbitor Date: Sat, 15 Apr 2023 21:08:16 +0200 Subject: [PATCH] fix thread replies --- src/components/views/Thread.jsx | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/src/components/views/Thread.jsx b/src/components/views/Thread.jsx index c8a4b4eb..06661970 100644 --- a/src/components/views/Thread.jsx +++ b/src/components/views/Thread.jsx @@ -61,6 +61,8 @@ const Thread = () => { useError(errorMessage, [errorMessage]); useSuccess(successMessage, [successMessage]); + const renderedComments = renderThreadComments(comment?.replies?.pages?.topAll.comments); + // temporary title from JSON, gets subplebbitAddress and threadCid from URL useEffect(() => { setSelectedAddress(subplebbitAddress); @@ -503,9 +505,7 @@ const Thread = () => { {comment.replyCount === undefined ? : null} {comment.replyCount > 0 && - Object.keys(comment?.replies?.pages?.topAll.comments).map(() => { - const renderedComments = renderThreadComments(comment?.replies?.pages?.topAll.comments); - return renderedComments.map(reply => { + renderedComments.map((reply) => { const replyMediaInfo = getCommentMediaInfo(reply); const fallbackImgUrl = "/assets/filedeleted-res.gif"; return ( @@ -515,25 +515,25 @@ const Thread = () => {
  - {reply.author.displayName - ? reply.author.displayName.length > 20 + {reply.author?.displayName + ? reply.author?.displayName.length > 20 ? <> - {reply.author.displayName.slice(0, 20) + " (...)"} + {reply.author?.displayName.slice(0, 20) + " (...)"} : - {reply.author.displayName} + {reply.author?.displayName} : Anonymous}   (u/ - {reply.author.shortAddress} + {reply.author?.shortAddress} ) @@ -614,7 +614,7 @@ const Thread = () => {
) }) - })} + }

@@ -720,25 +720,25 @@ const Thread = () => {
- {reply.author.displayName - ? reply.author.displayName.length > 12 + {reply.author?.displayName + ? reply.author?.displayName.length > 12 ? <> - {reply.author.displayName.slice(0, 12) + " (...)"} + {reply.author?.displayName.slice(0, 12) + " (...)"} : - {reply.author.displayName} + {reply.author?.displayName} : Anonymous}   (u/ - {reply.author.shortAddress} + {reply.author?.shortAddress} )