diff --git a/components/Comment.js b/components/Comment.js index 8689304..1c1e0bc 100644 --- a/components/Comment.js +++ b/components/Comment.js @@ -7,7 +7,21 @@ import Media from './Media.js'; import AwesomeIcon from 'react-native-vector-icons/FontAwesome'; -let Comment = ({ comment }) => { +let Comment = ({ comment, postid, viewer }) => { + let [likes, changeLikes] = useState(Object.keys(comment.reactions).length); + const newCommentReaction = () => { + if (!comment.reactions[viewer._id]) { + API.newCommentReaction(postid, comment.createdAt).then(() => { + comment.reactions[viewer._id] = { type: "like" }; + changeLikes(likes+1); + }); + } else { + //API.removePostReaction(viewer._id).then(() => { + // delete comment.reactions[viewer._id]; + // changeLikes(likes-1); + //}); + } + } return ( @@ -20,10 +34,10 @@ let Comment = ({ comment }) => { {comment.content} diff --git a/components/Post.js b/components/Post.js index 0ebff27..c15e734 100644 --- a/components/Post.js +++ b/components/Post.js @@ -37,7 +37,7 @@ let Post = (props) => { changePost(newPostObj); } const renderComment = ({ item }) => ( - + ); return (