aboutsummaryrefslogtreecommitdiff
path: root/src/screens
diff options
context:
space:
mode:
authorIvan Chen <ivan@tagg.id>2021-07-27 16:52:32 -0400
committerIvan Chen <ivan@tagg.id>2021-07-27 16:52:32 -0400
commitee8ccd2b48dee19c5526c1fccb613b718c0cf759 (patch)
tree5d574d5816a63d537c6ab5804f24714455a55a19 /src/screens
parentabf6bf12722845218f0947ca119f848c41dd12f4 (diff)
Add image moment upload action
Diffstat (limited to 'src/screens')
-rw-r--r--src/screens/profile/CaptionScreen.tsx68
1 files changed, 20 insertions, 48 deletions
diff --git a/src/screens/profile/CaptionScreen.tsx b/src/screens/profile/CaptionScreen.tsx
index 3ee0bd5b..f3b8788b 100644
--- a/src/screens/profile/CaptionScreen.tsx
+++ b/src/screens/profile/CaptionScreen.tsx
@@ -36,6 +36,7 @@ import * as RootNavigation from '../../RootNavigation';
import {MainStackParams} from '../../routes';
import {patchMoment, postMoment, postMomentTags} from '../../services';
import {
+ handleImageMomentUpload,
handleVideoMomentUpload,
loadUserMoments,
updateProfileCompletionStage,
@@ -138,11 +139,6 @@ const CaptionScreen: React.FC<CaptionScreenProps> = ({route, navigation}) => {
// then switch to the profile tab
navigation.popToTop();
RootNavigation.navigate('ProfileTab');
- setTimeout(() => {
- if (!isMediaAVideo) {
- Alert.alert(SUCCESS_PIC_UPLOAD);
- }
- }, 500);
} else {
// if editing, simply go back to profile screen
navigation.navigate('Profile', {
@@ -167,53 +163,29 @@ const CaptionScreen: React.FC<CaptionScreenProps> = ({route, navigation}) => {
handleFailed(true);
return;
}
- let profileCompletionStage;
- // separate upload logic for image/video
if (isMediaAVideo) {
- if (videoDuration) {
- dispatch(
- handleVideoMomentUpload(
- mediaUri,
- videoDuration,
- momentCategory,
- formattedTags(),
- ),
- );
- } else {
- handleFailed();
- return;
- }
- } else {
- const momentResponse = await postMoment(
- mediaUri,
- caption,
- momentCategory,
- userId,
+ dispatch(
+ handleVideoMomentUpload(
+ mediaUri,
+ videoDuration ?? 30,
+ momentCategory,
+ formattedTags(),
+ ),
);
- if (!momentResponse) {
- handleFailed();
- return;
- }
- profileCompletionStage = momentResponse.profile_completion_stage;
- const momentId = momentResponse.moment_id;
- if (momentId) {
- const momentTagResponse = await postMomentTags(
- momentId,
+ } else {
+ dispatch(
+ handleImageMomentUpload(
+ mediaUri,
+ caption,
+ momentCategory,
+ userId,
formattedTags(),
- );
- if (!momentTagResponse) {
- handleFailed();
- return;
- }
- }
- }
- if (!isMediaAVideo) {
- dispatch(loadUserMoments(userId));
- }
- if (profileCompletionStage) {
- dispatch(updateProfileCompletionStage(profileCompletionStage));
+ ),
+ );
}
- handleSuccess();
+ setTimeout(() => {
+ handleSuccess();
+ }, 500);
};
const handleSubmitEditChanges = async () => {