Compare commits
3 Commits
3e6ddab88d
...
52c8ab9eea
| Author | SHA1 | Date | |
|---|---|---|---|
| 52c8ab9eea | |||
| 475c490b16 | |||
| caf853e8a9 |
@@ -271,3 +271,7 @@ button {
|
||||
margin-left: 75%;
|
||||
width: 25%
|
||||
}
|
||||
|
||||
textarea {
|
||||
resize: none;
|
||||
}
|
||||
@@ -32,10 +32,10 @@ const Post = ({ post, recursionDepth, selectPost, reload }) => {
|
||||
postApi.reactToPost(post.id, null).then(reload);
|
||||
}
|
||||
|
||||
const getComments = (post) => {
|
||||
const getComments = (post, recursionDepth) => {
|
||||
let nrOfComments = post.comments.length;
|
||||
post.comments.forEach(comment => {
|
||||
nrOfComments += getComments(comment);
|
||||
if (recursionDepth !== 0) post.comments.forEach(comment => {
|
||||
nrOfComments += getComments(comment, recursionDepth - 1);
|
||||
})
|
||||
return nrOfComments;
|
||||
}
|
||||
@@ -51,10 +51,10 @@ const Post = ({ post, recursionDepth, selectPost, reload }) => {
|
||||
<p>{post.content}</p>
|
||||
</div>
|
||||
</div>
|
||||
<div className="nrOfComments">
|
||||
{recursionDepth !== 0 && <div className="nrOfComments">
|
||||
<FontAwesomeIcon className="icon" icon={faComments}/>
|
||||
<span className="">{getComments(post)}</span>
|
||||
</div>
|
||||
<span className="">{getComments(post, recursionDepth-1)}</span>
|
||||
</div>}
|
||||
<div className="post-right">
|
||||
<div className="post-date">
|
||||
{post.date.slice(8, 10) + "." + post.date.slice(5, 7) + "." + post.date.slice(0, 4)}
|
||||
|
||||
Reference in New Issue
Block a user