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}
)