Compare commits

..

3 Commits

2 changed files with 10 additions and 6 deletions

View File

@@ -271,3 +271,7 @@ button {
margin-left: 75%;
width: 25%
}
textarea {
resize: none;
}

View File

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