diff --git a/src/Components/Comments/SingleComment/ExpandedComment.js b/src/Components/Comments/SingleComment/ExpandedComment.js
index 6954424..275fdd6 100644
--- a/src/Components/Comments/SingleComment/ExpandedComment.js
+++ b/src/Components/Comments/SingleComment/ExpandedComment.js
@@ -1,34 +1,49 @@
import React from 'react'
+
const ExpandedComment = props => {
- const { text } = props
return (
-
+ props.showCollapseLink(props.id, true)}
+ onMouseLeave={() => props.showCollapseLink(props.id, false)}
+ >

+
-
username
-
- July 9 2019, 01:32:27 UTC
- {props.replies.length > 0 ? (
- props.toggleCollapse(props.id)}
- >
- collapse
-
- ) : (
- ''
- )}
-
+
+ username
+
+
+
+
{props.createdAt}
+ {props.replies.length > 0 ? (
+
props.toggleCollapse(props.id)}
+ >
+ collapse
+
+ ) : (
+ ''
+ )}
+
+ reply
+
- {text}
- reply
+ {props.text}
)
}
diff --git a/src/Components/Comments/index.js b/src/Components/Comments/index.js
index 21d4076..a429c9f 100644
--- a/src/Components/Comments/index.js
+++ b/src/Components/Comments/index.js
@@ -6,6 +6,16 @@ class ThreadList extends React.Component {
constructor() {
super()
this.toggleCollapse = this.toggleCollapse.bind(this)
+ this.showCollapseLink = this.showCollapseLink.bind(this)
+ }
+
+ showCollapseLink(id, collapsed) {
+ this.setState({ displayCollapse: 'block' })
+ const otherComments = this.props.comments.filter(c => c.id !== id)
+ const comment = this.props.comments.find(c => c.id === id)
+ comment['displayCollapse'] = collapsed
+ //console.log('displayed collapse for: ', comment)
+ this.setState({ comments: otherComments.concat(comment) })
}
toggleCollapse(id) {
@@ -24,18 +34,23 @@ class ThreadList extends React.Component {
(!c.parentId && !this.props.threadLevel) ||
c.parentId === this.props.threadLevel
)
+ if (comments.length === 0) {
+ return ''
+ }
console.log('showing comments for thread', this.props.threadLevel, comments)
return (