From 2f5f9df6dec1e905f3abf37d124ecd92d0e3a3d9 Mon Sep 17 00:00:00 2001 From: Ashm Walia Date: Wed, 27 Jan 2021 08:29:56 -0800 Subject: Pre-final --- src/components/comments/CommentTile.tsx | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src/components/comments/CommentTile.tsx') diff --git a/src/components/comments/CommentTile.tsx b/src/components/comments/CommentTile.tsx index f11c5e33..9a1607f7 100644 --- a/src/components/comments/CommentTile.tsx +++ b/src/components/comments/CommentTile.tsx @@ -30,6 +30,13 @@ const CommentTile: React.FC = ({ const timePosted = getTimePosted(comment_object.date_created); const [showReplies, setShowReplies] = useState(false); + /** + * Case : A COMMENT IS IN FOCUS && REPLY SECTION IS HIDDEN + * Bring the current comment to focus + * Case : No COMMENT IS IN FOCUS && REPLY SECTION IS SHOWN + * Unfocus comment in focus + * In any case toggle value of showReplies + */ const toggleReplies = () => { if (setCommentObjectInFocus) { if (!showReplies) { @@ -41,6 +48,9 @@ const CommentTile: React.FC = ({ setShowReplies(!showReplies); }; + /** + * Method to compute text to be shown for replies button + */ const getRepliesText = () => showReplies ? 'Hide' @@ -71,6 +81,8 @@ const CommentTile: React.FC = ({ {' ' + timePosted} + + {/*** Show replies text only if there are some replies present */} {typeOfComment === 'Comment' && comment_object.replies_count > 0 && ( {getRepliesText()} @@ -89,6 +101,8 @@ const CommentTile: React.FC = ({ + + {/*** Show replies if toggle state is true */} {showReplies && (