diff options
| author | Ivan Chen <ivan@tagg.id> | 2021-05-05 18:36:39 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-05-05 18:36:39 -0400 |
| commit | c9d32e68fbb9d1bc175722bfda49454a6f627eae (patch) | |
| tree | 5f7b3cf0937ca073f03dde2f84ce5c0e50a038a3 /src/components/moments/MomentPostContent.tsx | |
| parent | d4a04e31144f6cfaebb0b892e3593bb02bd49ed5 (diff) | |
| parent | 32a61c00756afb1aee0eb471ed643f24da1d3e85 (diff) | |
Merge pull request #401 from IvanIFChen/tma296-add-mentions
[TMA-296] Add mentions
Diffstat (limited to 'src/components/moments/MomentPostContent.tsx')
| -rw-r--r-- | src/components/moments/MomentPostContent.tsx | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/src/components/moments/MomentPostContent.tsx b/src/components/moments/MomentPostContent.tsx index d68ceaa3..03034925 100644 --- a/src/components/moments/MomentPostContent.tsx +++ b/src/components/moments/MomentPostContent.tsx @@ -1,8 +1,17 @@ +import {useNavigation} from '@react-navigation/native'; import React, {useEffect} from 'react'; import {Image, StyleSheet, Text, View, ViewProps} from 'react-native'; +import {useDispatch, useStore} from 'react-redux'; import {getCommentsCount} from '../../services'; -import {ScreenType} from '../../types'; -import {getTimePosted, SCREEN_HEIGHT, SCREEN_WIDTH} from '../../utils'; +import {RootState} from '../../store/rootReducer'; +import {ScreenType, UserType} from '../../types'; +import { + getTimePosted, + navigateToProfile, + SCREEN_HEIGHT, + SCREEN_WIDTH, +} from '../../utils'; +import {renderTextWithMentions} from '../../utils/comments'; import {CommentsCount} from '../comments'; interface MomentPostContentProps extends ViewProps { @@ -22,6 +31,9 @@ const MomentPostContent: React.FC<MomentPostContentProps> = ({ }) => { const [elapsedTime, setElapsedTime] = React.useState<string>(); const [comments_count, setCommentsCount] = React.useState(''); + const state: RootState = useStore().getState(); + const navigation = useNavigation(); + const dispatch = useDispatch(); useEffect(() => { const fetchCommentsCount = async () => { @@ -47,7 +59,12 @@ const MomentPostContent: React.FC<MomentPostContentProps> = ({ /> <Text style={styles.text}>{elapsedTime}</Text> </View> - <Text style={styles.captionText}>{caption}</Text> + {renderTextWithMentions({ + value: caption, + styles: styles.captionText, + onPress: (user: UserType) => + navigateToProfile(state, dispatch, navigation, screenType, user), + })} </View> ); }; |
