aboutsummaryrefslogtreecommitdiff
path: root/src/components/comments/CommentTile.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'src/components/comments/CommentTile.tsx')
-rw-r--r--src/components/comments/CommentTile.tsx14
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={{