aboutsummaryrefslogtreecommitdiff
path: root/src/screens/profile/CaptionScreen.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'src/screens/profile/CaptionScreen.tsx')
-rw-r--r--src/screens/profile/CaptionScreen.tsx26
1 files changed, 17 insertions, 9 deletions
diff --git a/src/screens/profile/CaptionScreen.tsx b/src/screens/profile/CaptionScreen.tsx
index 08dd8e5b..e9eed668 100644
--- a/src/screens/profile/CaptionScreen.tsx
+++ b/src/screens/profile/CaptionScreen.tsx
@@ -18,7 +18,9 @@ import {ProfileStackParams} from 'src/routes';
import {StackNavigationProp} from '@react-navigation/stack';
import {CaptionScreenHeader} from '../../components/';
import {MOMENTS_ENDPOINT} from '../../constants';
-import {AuthContext} from '../../routes/authentication';
+import {useDispatch, useSelector} from 'react-redux';
+import {loadUserMoments} from '../../store/actions';
+import {RootState} from '../../store/rootReducer';
/**
* Upload Screen to allow users to upload posts to Tagg
@@ -34,11 +36,11 @@ interface CaptionScreenProps {
}
const CaptionScreen: React.FC<CaptionScreenProps> = ({route, navigation}) => {
- const {title, image} = route.params;
+ const {title, image, screenType} = route.params;
const {
user: {userId},
- updateMoments,
- } = React.useContext(AuthContext);
+ } = useSelector((state: RootState) => state.user);
+ const dispatch = useDispatch();
const [caption, setCaption] = React.useState('');
const handleCaptionUpdate = (caption: string) => {
@@ -54,6 +56,14 @@ const CaptionScreen: React.FC<CaptionScreenProps> = ({route, navigation}) => {
return true;
};
+ const navigateToProfile = () => {
+ //Since the logged In User is navigating to own profile, useXId is not required
+ navigation.navigate('Profile', {
+ screenType,
+ userXId: undefined,
+ });
+ };
+
const handleShare = async () => {
try {
const request = new FormData();
@@ -86,8 +96,8 @@ const CaptionScreen: React.FC<CaptionScreenProps> = ({route, navigation}) => {
let data = await response.json();
if (statusCode === 200 && checkImageUploadStatus(data)) {
Alert.alert('The picture was uploaded successfully!');
- updateMoments(true);
- navigation.navigate('Profile', {isProfileView: false});
+ dispatch(loadUserMoments(userId));
+ navigateToProfile();
} else {
Alert.alert('An error occured while uploading. Please try again!');
}
@@ -107,9 +117,7 @@ const CaptionScreen: React.FC<CaptionScreenProps> = ({route, navigation}) => {
<Button
title="Cancel"
buttonStyle={styles.button}
- onPress={() => {
- navigation.navigate('Profile', {isProfileView: false});
- }}
+ onPress={() => navigateToProfile()}
/>
<Button
title="Share"