aboutsummaryrefslogtreecommitdiff
path: root/src/screens/profile/CaptionScreen.tsx
diff options
context:
space:
mode:
authorAshm Walia <40498934+ashmgarv@users.noreply.github.com>2020-12-04 08:50:24 -0800
committerGitHub <noreply@github.com>2020-12-04 11:50:24 -0500
commit0fd892ad288f2e1eaaa4fdf5e1fd6f15dbd45860 (patch)
treed7d53d94c6c4026ac9b325508ebce4706d412ac4 /src/screens/profile/CaptionScreen.tsx
parentf620102190629e0b6f180d3ce056d850b1db5aaa (diff)
[TMA - 398 AND TMA-430] Replace Providers with Redux Store (#125)
* First * WIP * Thunk * Some more comments * sc * recent searches and follounfollow * Edit profile dummy * Block / unblock and some cleanup * Replace auth provider * Sc * Delete AP after rebase * Discover users * Cleanup * More cleanup * Replace profile provider * Fixed build failure * Fixed a bug reported * Prevent app crash when backend server is down
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"