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.tsx39
1 files changed, 22 insertions, 17 deletions
diff --git a/src/screens/profile/CaptionScreen.tsx b/src/screens/profile/CaptionScreen.tsx
index 7f77bdca..88ff0ecc 100644
--- a/src/screens/profile/CaptionScreen.tsx
+++ b/src/screens/profile/CaptionScreen.tsx
@@ -42,6 +42,7 @@ import {
postMomentTags,
} from '../../services';
import {
+ handleVideoMomentUpload,
loadUserMoments,
updateProfileCompletionStage,
} from '../../store/actions';
@@ -76,6 +77,8 @@ const CaptionScreen: React.FC<CaptionScreenProps> = ({route, navigation}) => {
const [tags, setTags] = useState<MomentTagType[]>([]);
const [taggedUsersText, setTaggedUsersText] = useState('');
const [momentCategory, setMomentCategory] = useState<string | undefined>();
+ // only used for upload purposes, undefined for editing is fine
+ const videoDuration = moment ? undefined : route.params.media!.videoDuration;
const mediaUri = moment ? moment.moment_url : route.params.media!.uri;
// TODO: change this once moment refactor is done
const isMediaAVideo = moment
@@ -166,18 +169,17 @@ const CaptionScreen: React.FC<CaptionScreenProps> = ({route, navigation}) => {
return;
}
let profileCompletionStage;
- let momentId;
// separate upload logic for image/video
if (isMediaAVideo) {
- const presignedURLResponse = await handlePresignedURL(momentCategory);
- if (!presignedURLResponse) {
- handleFailed();
- return;
- }
- momentId = presignedURLResponse.moment_id;
- const fileHash = presignedURLResponse.response_url.fields.key;
- if (fileHash !== null && fileHash !== '' && fileHash !== undefined) {
- await handleVideoUpload(mediaUri, presignedURLResponse);
+ if (videoDuration) {
+ dispatch(
+ handleVideoMomentUpload(
+ mediaUri,
+ videoDuration,
+ momentCategory,
+ formattedTags(),
+ ),
+ );
} else {
handleFailed();
}
@@ -193,13 +195,16 @@ const CaptionScreen: React.FC<CaptionScreenProps> = ({route, navigation}) => {
return;
}
profileCompletionStage = momentResponse.profile_completion_stage;
- momentId = momentResponse.moment_id;
- }
- if (momentId) {
- const momentTagResponse = await postMomentTags(momentId, formattedTags());
- if (!momentTagResponse) {
- handleFailed();
- return;
+ const momentId = momentResponse.moment_id;
+ if (momentId) {
+ const momentTagResponse = await postMomentTags(
+ momentId,
+ formattedTags(),
+ );
+ if (!momentTagResponse) {
+ handleFailed();
+ return;
+ }
}
}
if (!isMediaAVideo) {