diff options
Diffstat (limited to 'src/components/comments')
-rw-r--r-- | src/components/comments/CommentTile.tsx | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/src/components/comments/CommentTile.tsx b/src/components/comments/CommentTile.tsx index 1f1fafda..ee32f889 100644 --- a/src/components/comments/CommentTile.tsx +++ b/src/components/comments/CommentTile.tsx @@ -55,6 +55,7 @@ const CommentTile: React.FC<CommentTileProps> = ({ const [showReplies, setShowReplies] = useState<boolean>(false); const [showKeyboard, setShowKeyboard] = useState<boolean>(false); const [shouldUpdateChild, setShouldUpdateChild] = useState(true); + const [liked, setLiked] = useState(commentObject.user_reaction !== null); const swipeRef = useRef<Swipeable>(null); const {replyPosted} = useSelector((state: RootState) => state.user); const state: RootState = useStore().getState(); @@ -150,12 +151,9 @@ const CommentTile: React.FC<CommentTileProps> = ({ screenType={screenType} /> <LikeButton - initialLikeState={commentObject.user_reaction !== null} - onPress={() => { - handleLikeUnlikeComment(commentObject).then(() => { - setShouldUpdateParent(true); - }); - }} + liked={liked} + setLiked={setLiked} + onPress={() => handleLikeUnlikeComment(commentObject, liked)} style={styles.likeButton} /> </View> @@ -183,7 +181,9 @@ const CommentTile: React.FC<CommentTileProps> = ({ }); }}> <Text style={[styles.date_time, styles.likeCount]}> - {commentObject.reaction_count} + {commentObject.user_reaction !== null + ? commentObject.reaction_count + (liked ? 0 : -1) + : commentObject.reaction_count + (liked ? 1 : 0)} </Text> <Text style={styles.date_time}>Likes</Text> </TouchableOpacity> |