diff options
author | Ivan Chen <ivan@tagg.id> | 2021-05-04 20:46:27 -0400 |
---|---|---|
committer | Ivan Chen <ivan@tagg.id> | 2021-05-04 20:48:09 -0400 |
commit | 7f9799c6693254f8eb6729c0977826694c28c437 (patch) | |
tree | 48d119dfa78008b4c6fe44598eb38bf21da0c444 /src/components/comments/CommentTile.tsx | |
parent | c23feea922da063d88d031f25b72b53ba593ec04 (diff) |
added navigation to profile
Diffstat (limited to 'src/components/comments/CommentTile.tsx')
-rw-r--r-- | src/components/comments/CommentTile.tsx | 34 |
1 files changed, 24 insertions, 10 deletions
diff --git a/src/components/comments/CommentTile.tsx b/src/components/comments/CommentTile.tsx index 12f32c95..ce346af5 100644 --- a/src/components/comments/CommentTile.tsx +++ b/src/components/comments/CommentTile.tsx @@ -1,9 +1,10 @@ +import {useNavigation} from '@react-navigation/native'; import React, {Fragment, useContext, useEffect, useRef, useState} from 'react'; import {Alert, Animated, StyleSheet} from 'react-native'; import {Text, View} from 'react-native-animatable'; import {RectButton, TouchableOpacity} from 'react-native-gesture-handler'; import Swipeable from 'react-native-gesture-handler/Swipeable'; -import {useSelector} from 'react-redux'; +import {useDispatch, useSelector, useStore} from 'react-redux'; import Arrow from '../../assets/icons/back-arrow-colored.svg'; import ClockIcon from '../../assets/icons/clock-icon-01.svg'; import Trash from '../../assets/ionicons/trash-outline.svg'; @@ -12,9 +13,19 @@ import {ERROR_FAILED_TO_DELETE_COMMENT} from '../../constants/strings'; import {CommentContext} from '../../screens/profile/MomentCommentsScreen'; import {deleteComment, getCommentsCount} from '../../services'; import {RootState} from '../../store/rootReducer'; -import {CommentThreadType, CommentType, ScreenType} from '../../types'; -import {getTimePosted, normalize, SCREEN_WIDTH} from '../../utils'; -import {mentionPartTypes, renderTextWithMentions} from '../../utils/comments'; +import { + CommentThreadType, + CommentType, + ScreenType, + UserType, +} from '../../types'; +import { + getTimePosted, + navigateToProfile, + normalize, + SCREEN_WIDTH, +} from '../../utils'; +import {renderTextWithMentions} from '../../utils/comments'; import {ProfilePreview} from '../profile'; import CommentsContainer from './CommentsContainer'; @@ -46,6 +57,9 @@ const CommentTile: React.FC<CommentTileProps> = ({ const [shouldUpdateChild, setShouldUpdateChild] = useState(true); const swipeRef = useRef<Swipeable>(null); const {replyPosted} = useSelector((state: RootState) => state.user); + const state: RootState = useStore().getState(); + const navigation = useNavigation(); + const dispatch = useDispatch(); useEffect(() => { if (shouldUpdateParent) { @@ -135,12 +149,12 @@ const CommentTile: React.FC<CommentTileProps> = ({ screenType={screenType} /> <TouchableOpacity style={styles.body} onPress={toggleAddComment}> - <View style={styles.comment}> - {renderTextWithMentions({ - value: commentObject.comment, - partTypes: mentionPartTypes, - })} - </View> + {renderTextWithMentions({ + value: commentObject.comment, + styles: styles.comment, + onPress: (user: UserType) => + navigateToProfile(state, dispatch, navigation, screenType, user), + })} <View style={styles.clockIconAndTime}> <ClockIcon style={styles.clockIcon} /> <Text style={styles.date_time}>{' ' + timePosted}</Text> |