aboutsummaryrefslogtreecommitdiff
path: root/src/components/moments/MomentPostContent.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'src/components/moments/MomentPostContent.tsx')
-rw-r--r--src/components/moments/MomentPostContent.tsx31
1 files changed, 9 insertions, 22 deletions
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<MomentPostContentProps> = ({
screenType,
- momentId,
- caption,
- pathHash,
- dateTime,
+ moment,
style,
momentTags,
}) => {
@@ -38,7 +31,6 @@ const MomentPostContent: React.FC<MomentPostContentProps> = ({
const navigation = useNavigation();
const dispatch = useDispatch();
const [elapsedTime, setElapsedTime] = useState('');
- const [comments_count, setCommentsCount] = useState('');
const [tags, setTags] = useState<MomentTagType[]>(momentTags);
const imageRef = useRef(null);
const [visible, setVisible] = useState(false);
@@ -52,13 +44,8 @@ const MomentPostContent: React.FC<MomentPostContentProps> = ({
}, [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<MomentPostContentProps> = ({
<Image
ref={imageRef}
style={styles.image}
- source={{uri: pathHash}}
+ source={{uri: moment.moment_url}}
resizeMode={'cover'}
/>
{tags.length > 0 && (
@@ -103,14 +90,14 @@ const MomentPostContent: React.FC<MomentPostContentProps> = ({
)}
<View style={styles.footerContainer}>
<CommentsCount
- commentsCount={comments_count}
- momentId={momentId}
+ commentsCount={moment.comments_count.toString()}
+ momentId={moment.moment_id}
screenType={screenType}
/>
<Text style={styles.text}>{elapsedTime}</Text>
</View>
{renderTextWithMentions({
- value: caption,
+ value: moment.caption,
styles: styles.captionText,
partTypes: mentionPartTypes('white'),
onPress: (user: UserType) =>