diff options
author | Ivan Chen <ivan@tagg.id> | 2021-06-23 17:08:31 -0400 |
---|---|---|
committer | Ivan Chen <ivan@tagg.id> | 2021-06-23 17:08:31 -0400 |
commit | 9f835e1b82647477ec959a62b02dee4e9351b1b5 (patch) | |
tree | 7f8f8b2f11fad22ad94e862fdebff5eea476cd3b | |
parent | 345a20590da5fd1cabc85c4e7b0b72c05e1f0665 (diff) |
Clean up video upload logic
-rw-r--r-- | src/screens/profile/CaptionScreen.tsx | 20 | ||||
-rw-r--r-- | src/services/MomentService.ts | 5 | ||||
-rw-r--r-- | src/types/types.ts | 1 |
3 files changed, 10 insertions, 16 deletions
diff --git a/src/screens/profile/CaptionScreen.tsx b/src/screens/profile/CaptionScreen.tsx index 1b96face..d53570cb 100644 --- a/src/screens/profile/CaptionScreen.tsx +++ b/src/screens/profile/CaptionScreen.tsx @@ -147,19 +147,13 @@ const CaptionScreen: React.FC<CaptionScreenProps> = ({route, navigation}) => { // separate upload logic for image/video if (isMediaAVideo) { const presignedURL = await handlePresignedURL(mediaFilename, title); - // TOOD: ignoring type error for PoC reason - const response: { - response_msg: string; - response_url: string; - moment_id: string; - } = handleVideoUpload( - { - filename: mediaFilename, - sourceURL: mediaUri, - }, - presignedURL, - ); - momentId = response.moment_id; + if (!presignedURL) { + handleFailed(); + return; + } + momentId = presignedURL.moment_id; + // TODO: assume success for now + await handleVideoUpload(mediaFilename, mediaUri, presignedURL); } else { const momentResponse = await postMoment( mediaFilename, diff --git a/src/services/MomentService.ts b/src/services/MomentService.ts index da1bfb97..ca32a3f3 100644 --- a/src/services/MomentService.ts +++ b/src/services/MomentService.ts @@ -311,7 +311,7 @@ export const handleVideoUpload = async ( // let data = await response.json(); if (status === 200 || status === 204) { console.log('complete'); - return response; + return true; } else { if (status === 404) { console.log( @@ -323,11 +323,10 @@ export const handleVideoUpload = async ( console.log(ERROR_SOMETHING_WENT_WRONG_REFRESH); } console.log(response); - return false; } } catch (error) { console.log(error); console.log(ERROR_SOMETHING_WENT_WRONG); - return false; } + return false; }; diff --git a/src/types/types.ts b/src/types/types.ts index f6f23fc8..416d9146 100644 --- a/src/types/types.ts +++ b/src/types/types.ts @@ -379,4 +379,5 @@ export type PresignedURLResponse = { 'x-amz-signature': string; }; }; + moment_id: string; }; |