diff options
author | Ivan Chen <ivan@tagg.id> | 2021-06-09 20:55:44 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-06-09 20:55:44 -0400 |
commit | e58c398eff2de37d8c599ccc82e4f592d755601b (patch) | |
tree | f2e7a44c34f5877d59e4e27c132d2c1029174000 /src | |
parent | 117996a44ffdb7c9c517ab58ad8ea5cbe0dd01f1 (diff) | |
parent | d1d6556d02f56ca03350e04de7f466fa13c7d96c (diff) |
Merge pull request #461 from shravyaramesh/tma915-navigate-back-on-editing
[TMA-915] Navigate to moment view and refresh for after editing
Diffstat (limited to 'src')
-rw-r--r-- | src/components/moments/MomentPost.tsx | 2 | ||||
-rw-r--r-- | src/screens/profile/CaptionScreen.tsx | 25 |
2 files changed, 19 insertions, 8 deletions
diff --git a/src/components/moments/MomentPost.tsx b/src/components/moments/MomentPost.tsx index e744fcd9..b659177d 100644 --- a/src/components/moments/MomentPost.tsx +++ b/src/components/moments/MomentPost.tsx @@ -40,7 +40,7 @@ const MomentPost: React.FC<MomentPostProps> = ({item, userXId, screenType}) => { */ useEffect(() => { loadTags(); - }, []); + }, [item]); /* * Check if loggedInUser has been tagged in the picture and set the id diff --git a/src/screens/profile/CaptionScreen.tsx b/src/screens/profile/CaptionScreen.tsx index 949b61fd..9e1b4674 100644 --- a/src/screens/profile/CaptionScreen.tsx +++ b/src/screens/profile/CaptionScreen.tsx @@ -21,7 +21,11 @@ import {SearchBackground} from '../../components'; import {CaptionScreenHeader} from '../../components/'; import TaggLoadingIndicator from '../../components/common/TaggLoadingIndicator'; import {TAGG_LIGHT_BLUE_2} from '../../constants'; -import {ERROR_UPLOAD, SUCCESS_PIC_UPLOAD} from '../../constants/strings'; +import { + ERROR_SOMETHING_WENT_WRONG_REFRESH, + ERROR_UPLOAD, + SUCCESS_PIC_UPLOAD, +} from '../../constants/strings'; import {MainStackParams} from '../../routes'; import {patchMoment, postMoment, postMomentTags} from '../../services'; import { @@ -89,15 +93,20 @@ const CaptionScreen: React.FC<CaptionScreenProps> = ({route, navigation}) => { const handleFailed = () => { setLoading(false); setTimeout(() => { - Alert.alert(moment ? 'Error editing moment' : ERROR_UPLOAD); + Alert.alert(moment ? ERROR_SOMETHING_WENT_WRONG_REFRESH : ERROR_UPLOAD); }, 500); }; const handleSuccess = () => { setLoading(false); - navigateToProfile(); - setTimeout(() => { - Alert.alert(moment ? 'Successfully edited moment!' : SUCCESS_PIC_UPLOAD); - }, 500); + if (moment) { + setLoading(false); + navigation.goBack(); + } else { + navigateToProfile(); + setTimeout(() => { + Alert.alert(SUCCESS_PIC_UPLOAD); + }, 500); + } }; const formattedTags = () => { @@ -169,7 +178,9 @@ const CaptionScreen: React.FC<CaptionScreenProps> = ({route, navigation}) => { <Button title="Cancel" buttonStyle={styles.button} - onPress={() => navigateToProfile()} + onPress={() => + moment ? navigation.goBack() : navigateToProfile() + } /> <Button title={moment ? 'Done' : 'Share'} |