aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/components/moments/MomentPost.tsx5
-rw-r--r--src/components/moments/MomentPostContent.tsx31
-rw-r--r--src/components/moments/MomentPostHeader.tsx3
3 files changed, 12 insertions, 27 deletions
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<MomentPostProps> = ({
/>
<MomentPostContent
style={styles.postContent}
- momentId={moment.moment_id}
- caption={moment.caption}
- pathHash={moment.moment_url}
- dateTime={moment.date_created}
+ moment={moment}
screenType={screenType}
momentTags={tags}
/>
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) =>
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<MomentPostHeaderProps> = ({
style={styles.avatar}
userXId={userXId}
screenType={screenType}
+ editable={false}
/>
<Text style={styles.headerText}>{username}</Text>
</TouchableOpacity>
@@ -74,7 +75,7 @@ const MomentPostHeader: React.FC<MomentPostHeaderProps> = ({
removeTag={removeTag}
dismissScreenAndUpdate={() => {
dispatch(loadUserMoments(loggedInUserId));
- navigation.pop();
+ navigation.goBack();
}}
/>
</View>