From 2f5f9df6dec1e905f3abf37d124ecd92d0e3a3d9 Mon Sep 17 00:00:00 2001
From: Ashm Walia <ashmwalia@outlook.com>
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<CommentTileProps> = ({
   const timePosted = getTimePosted(comment_object.date_created);
   const [showReplies, setShowReplies] = useState<boolean>(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<CommentTileProps> = ({
     setShowReplies(!showReplies);
   };
 
+  /**
+   * Method to compute text to be shown for replies button
+   */
   const getRepliesText = () =>
     showReplies
       ? 'Hide'
@@ -71,6 +81,8 @@ const CommentTile: React.FC<CommentTileProps> = ({
             <ClockIcon style={styles.clockIcon} />
             <Text style={styles.date_time}>{' ' + timePosted}</Text>
             <View style={styles.flexer} />
+
+            {/*** Show replies text only if there are some replies present */}
             {typeOfComment === 'Comment' && comment_object.replies_count > 0 && (
               <View style={styles.repliesTextAndIconContainer}>
                 <Text style={styles.repliesText}>{getRepliesText()}</Text>
@@ -89,6 +101,8 @@ const CommentTile: React.FC<CommentTileProps> = ({
           </View>
         </TouchableOpacity>
       </View>
+
+      {/*** Show replies if toggle state is true */}
       {showReplies && (
         <View
           style={{
-- 
cgit v1.2.3-70-g09d2

