diff options
author | Ashm Walia <ashmwalia@outlook.com> | 2021-01-27 08:29:56 -0800 |
---|---|---|
committer | Ashm Walia <ashmwalia@outlook.com> | 2021-01-27 08:29:56 -0800 |
commit | 2f5f9df6dec1e905f3abf37d124ecd92d0e3a3d9 (patch) | |
tree | 0b34914b1af54c66031808c52da65395b7905fff /src/components/comments/CommentTile.tsx | |
parent | 85c0f668665696ba8127ee1ea436d10ec0af955f (diff) |
Pre-final
Diffstat (limited to 'src/components/comments/CommentTile.tsx')
-rw-r--r-- | src/components/comments/CommentTile.tsx | 14 |
1 files changed, 14 insertions, 0 deletions
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={{ |