diff options
author | Ivan Chen <ivan@tagg.id> | 2021-06-10 17:23:47 -0400 |
---|---|---|
committer | Ivan Chen <ivan@tagg.id> | 2021-06-10 17:23:47 -0400 |
commit | 770dcf385fa99fbb93c4ae89a51b09fd96d23bf9 (patch) | |
tree | b6463d6827582fa6081dfe89cf98826e1e9a00ea /src/components/moments/MomentPostContent.tsx | |
parent | d4c65c0ba3de95adf3069500491b124df453660f (diff) |
Add util function, Add logic for updating comment preview
Diffstat (limited to 'src/components/moments/MomentPostContent.tsx')
-rw-r--r-- | src/components/moments/MomentPostContent.tsx | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/src/components/moments/MomentPostContent.tsx b/src/components/moments/MomentPostContent.tsx index 378931d1..5192fdf0 100644 --- a/src/components/moments/MomentPostContent.tsx +++ b/src/components/moments/MomentPostContent.tsx @@ -5,12 +5,19 @@ import {TouchableWithoutFeedback} from 'react-native-gesture-handler'; import Animated, {EasingNode} from 'react-native-reanimated'; import {useDispatch, useStore} from 'react-redux'; import {RootState} from '../../store/rootReducer'; -import {MomentPostType, MomentTagType, ScreenType, UserType} from '../../types'; +import { + MomentCommentPreviewType, + MomentPostType, + MomentTagType, + ScreenType, + UserType, +} from '../../types'; import { getTimePosted, navigateToProfile, normalize, SCREEN_WIDTH, + getLoggedInUserAsProfilePreview, } from '../../utils'; import {mentionPartTypes, renderTextWithMentions} from '../../utils/comments'; import {AddComment} from '../comments'; @@ -37,6 +44,8 @@ const MomentPostContent: React.FC<MomentPostContentProps> = ({ const [fadeValue, setFadeValue] = useState<Animated.Value<number>>( new Animated.Value(0), ); + const [commentPreview, setCommentPreview] = + useState<MomentCommentPreviewType | null>(moment.comment_preview); useEffect(() => { setTags(momentTags); @@ -91,10 +100,21 @@ const MomentPostContent: React.FC<MomentPostContentProps> = ({ onPress: (user: UserType) => navigateToProfile(state, dispatch, navigation, screenType, user), })} - <MomentCommentPreview moment={moment} screenType={screenType} /> + <MomentCommentPreview + momentId={moment.moment_id} + commentsCount={moment.comments_count} + commentPreview={commentPreview} + screenType={screenType} + /> <AddComment placeholderText={'Add a comment here!'} momentId={moment.moment_id} + callback={(message) => + setCommentPreview({ + commenter: getLoggedInUserAsProfilePreview(state), + comment: message, + }) + } theme={'dark'} /> <Text style={styles.text}>{getTimePosted(moment.date_created)}</Text> |