diff --git a/src/components/Thread.jsx b/src/components/Thread.jsx index 0c5301c1..6a7f67a1 100644 --- a/src/components/Thread.jsx +++ b/src/components/Thread.jsx @@ -119,18 +119,24 @@ const Thread = ({ setBodyStyle }) => { window.scrollTo(0, 0); } + const handleClickBottom = () => { + window.scrollTo(0, document.body.scrollHeight); + } + function renderComments(comments) { - return comments.map(comment => { - const { replyCount, replies: { pages: { topAll: { comments: nestedComments } } } } = comment; - - if (replyCount > 0 && nestedComments.length > 0) { + const commentKeys = Object.keys(comments); + const renderedComments = commentKeys.map(key => { + const comment = comments[key]; + const { replies: { pages: { topAll: { comments: nestedComments } } } } = comment; + if (comment.replyCount > 0 && nestedComments) { const renderedNestedComments = renderComments(nestedComments); return [comment, ...renderedNestedComments]; } - return [comment]; }).flat(); + return renderedComments; } + return ( @@ -227,6 +233,16 @@ const Thread = ({ setBodyStyle }) => { Return ] + + [ + Catalog + ] + + + [ + event.target.style.cursor='pointer'} onTouchStart={handleClickTop}>Bottom + ] + {comment ? ( comment.replyCount > 0 ? ( {comment.replyCount} replies @@ -282,85 +298,75 @@ const Thread = ({ setBodyStyle }) => { - -
- - [ - Return - ] - - - [ - Catalog - ] - - - [ - event.target.style.cursor='pointer'}>Top - ] - - - [ - event.target.style.cursor='pointer'}>Post a Reply - ] - - {comment.replyCount > 0 ? ( - {comment.replyCount} replies - ) : ( - No replies yet - )} -
-
- <> - - {/* {comment ? ( - comment.map(thread => { + {comment.replyCount > 0 && + Object.keys(comment.replies.pages.topAll.comments).map(() => { + const renderedComments = renderComments(comment.replies.pages.topAll.comments); + return renderedComments.map(reply => { let counter = 1; - const { replies: { pages: { topAll: { comments } } } } = thread; - const renderedComments = renderComments(comments); + counter++; + const counterString = counter.toString().padStart(8, '0'); return ( - <> - {renderedComments.map(reply => { - counter++; - const counterString = counter.toString().padStart(8, '0'); - return ( -
-
{'>>'}
-
-
+
+
{'>>'}
+
+
+   + + {reply.author.displayName || "Anonymous"}   - - {reply.author.displayName || "Anonymous"} -   - - (User: {reply.author.address}) - - -   - 2 weeks ago -   - - No. - {counterString} - - -
-
- - {`>>${counterString}`}{
} -
- {reply.content} -
-
+ + (User: {reply.author.address}) + + +   + 2 weeks ago +   + + No. + {counterString} + +
- ) - })} - +
+ + {`>>${counterString}`}{
} +
+ {reply.content} +
+
+
) }) - ) : ( -
Loading...
- )} */} + })} + +
+ + [ + Return + ] + + + [ + Catalog + ] + + + [ + event.target.style.cursor='pointer'} onTouchStart={handleClickTop}>Top + ] + + + [ + event.target.style.cursor='pointer'}>Post a Reply + ] + + {comment.replyCount > 0 ? ( + {comment.replyCount} replies + ) : ( + No replies yet + )} +
+
) : ( diff --git a/src/components/styles/Thread.styled.jsx b/src/components/styles/Thread.styled.jsx index 79096874..df4bb880 100644 --- a/src/components/styles/Thread.styled.jsx +++ b/src/components/styles/Thread.styled.jsx @@ -482,6 +482,10 @@ export const TopBar = styled.div` margin-top: 4px; } + .catalog-button { + margin-left: 3px !important; + } + ${({ selectedStyle }) => { switch (selectedStyle) { case 'Yotsuba': @@ -554,6 +558,7 @@ export const TopBar = styled.div` a, a:visited { color: #00e !important; + text-decoration: underline; } a:hover { @@ -584,6 +589,7 @@ export const TopBar = styled.div` a, a:visited { color: #34345c !important; + text-decoration: underline; } a:hover {