Compare commits

...

3 Commits

2 changed files with 10 additions and 6 deletions

View File

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

View File

@@ -32,10 +32,10 @@ const Post = ({ post, recursionDepth, selectPost, reload }) => {
postApi.reactToPost(post.id, null).then(reload); postApi.reactToPost(post.id, null).then(reload);
} }
const getComments = (post) => { const getComments = (post, recursionDepth) => {
let nrOfComments = post.comments.length; let nrOfComments = post.comments.length;
post.comments.forEach(comment => { if (recursionDepth !== 0) post.comments.forEach(comment => {
nrOfComments += getComments(comment); nrOfComments += getComments(comment, recursionDepth - 1);
}) })
return nrOfComments; return nrOfComments;
} }
@@ -51,10 +51,10 @@ const Post = ({ post, recursionDepth, selectPost, reload }) => {
<p>{post.content}</p> <p>{post.content}</p>
</div> </div>
</div> </div>
<div className="nrOfComments"> {recursionDepth !== 0 && <div className="nrOfComments">
<FontAwesomeIcon className="icon" icon={faComments}/> <FontAwesomeIcon className="icon" icon={faComments}/>
<span className="">{getComments(post)}</span> <span className="">{getComments(post, recursionDepth-1)}</span>
</div> </div>}
<div className="post-right"> <div className="post-right">
<div className="post-date"> <div className="post-date">
{post.date.slice(8, 10) + "." + post.date.slice(5, 7) + "." + post.date.slice(0, 4)} {post.date.slice(8, 10) + "." + post.date.slice(5, 7) + "." + post.date.slice(0, 4)}