From be1df6bb00e89c92da9a33d0375cfecb441d3a23 Mon Sep 17 00:00:00 2001 From: Ivan Chen Date: Tue, 8 Jun 2021 14:53:28 -0400 Subject: Cleanup code, Add comment count --- src/components/moments/MomentPost.tsx | 5 +---- src/components/moments/MomentPostContent.tsx | 31 ++++++++-------------------- src/components/moments/MomentPostHeader.tsx | 3 ++- 3 files changed, 12 insertions(+), 27 deletions(-) (limited to 'src') diff --git a/src/components/moments/MomentPost.tsx b/src/components/moments/MomentPost.tsx index 4f8bb63f..ffdbed81 100644 --- a/src/components/moments/MomentPost.tsx +++ b/src/components/moments/MomentPost.tsx @@ -85,10 +85,7 @@ const MomentPost: React.FC = ({ /> diff --git a/src/components/moments/MomentPostContent.tsx b/src/components/moments/MomentPostContent.tsx index dcad9aca..c59a9c39 100644 --- a/src/components/moments/MomentPostContent.tsx +++ b/src/components/moments/MomentPostContent.tsx @@ -4,9 +4,8 @@ import {Image, StyleSheet, Text, View, ViewProps} from 'react-native'; import {TouchableWithoutFeedback} from 'react-native-gesture-handler'; import Animated, {EasingNode} from 'react-native-reanimated'; import {useDispatch, useStore} from 'react-redux'; -import {getCommentsCount} from '../../services'; import {RootState} from '../../store/rootReducer'; -import {MomentTagType, ScreenType, UserType} from '../../types'; +import {MomentPostType, MomentTagType, ScreenType, UserType} from '../../types'; import { getTimePosted, navigateToProfile, @@ -19,18 +18,12 @@ import {MomentTags} from '../common'; interface MomentPostContentProps extends ViewProps { screenType: ScreenType; - momentId: string; - caption: string; - pathHash: string; - dateTime: string; + moment: MomentPostType; momentTags: MomentTagType[]; } const MomentPostContent: React.FC = ({ screenType, - momentId, - caption, - pathHash, - dateTime, + moment, style, momentTags, }) => { @@ -38,7 +31,6 @@ const MomentPostContent: React.FC = ({ const navigation = useNavigation(); const dispatch = useDispatch(); const [elapsedTime, setElapsedTime] = useState(''); - const [comments_count, setCommentsCount] = useState(''); const [tags, setTags] = useState(momentTags); const imageRef = useRef(null); const [visible, setVisible] = useState(false); @@ -52,13 +44,8 @@ const MomentPostContent: React.FC = ({ }, [momentTags]); useEffect(() => { - const fetchCommentsCount = async () => { - const count = await getCommentsCount(momentId, false); - setCommentsCount(count); - }; - setElapsedTime(getTimePosted(dateTime)); - fetchCommentsCount(); - }, [dateTime, momentId]); + setElapsedTime(getTimePosted(moment.date_created)); + }, [moment.date_created]); useEffect(() => { const fade = async () => { @@ -81,7 +68,7 @@ const MomentPostContent: React.FC = ({ {tags.length > 0 && ( @@ -103,14 +90,14 @@ const MomentPostContent: React.FC = ({ )} {elapsedTime} {renderTextWithMentions({ - value: caption, + value: moment.caption, styles: styles.captionText, partTypes: mentionPartTypes('white'), onPress: (user: UserType) => diff --git a/src/components/moments/MomentPostHeader.tsx b/src/components/moments/MomentPostHeader.tsx index dc6a3cd9..64581e06 100644 --- a/src/components/moments/MomentPostHeader.tsx +++ b/src/components/moments/MomentPostHeader.tsx @@ -62,6 +62,7 @@ const MomentPostHeader: React.FC = ({ style={styles.avatar} userXId={userXId} screenType={screenType} + editable={false} /> {username} @@ -74,7 +75,7 @@ const MomentPostHeader: React.FC = ({ removeTag={removeTag} dismissScreenAndUpdate={() => { dispatch(loadUserMoments(loggedInUserId)); - navigation.pop(); + navigation.goBack(); }} /> -- cgit v1.2.3-70-g09d2