From 9a043ad37aefb5c1b5908c4171cef36977acd5f4 Mon Sep 17 00:00:00 2001 From: Ivan Chen Date: Fri, 23 Jul 2021 14:48:37 -0400 Subject: Fix finish process check issue, Adjust progress bar timing --- src/components/moments/MomentUploadProgressBar.tsx | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) (limited to 'src/components') diff --git a/src/components/moments/MomentUploadProgressBar.tsx b/src/components/moments/MomentUploadProgressBar.tsx index 0c93ea95..9412fcd6 100644 --- a/src/components/moments/MomentUploadProgressBar.tsx +++ b/src/components/moments/MomentUploadProgressBar.tsx @@ -8,7 +8,7 @@ import { withTiming, } from 'react-native-reanimated'; import {useDispatch, useSelector} from 'react-redux'; -import {checkMomentUploadFinished} from '../../services'; +import {checkMomentDoneProcessing} from '../../services'; import {loadUserMoments} from '../../store/actions'; import {setMomentUploadProgressBar} from '../../store/reducers'; import {RootState} from '../../store/rootReducer'; @@ -36,10 +36,10 @@ const MomentUploadProgressBar: React.FC = useEffect(() => { let doneProcessing = false; - const checkDone = () => { + const checkDone = async () => { if ( momentUploadProgressBar && - checkMomentUploadFinished(momentUploadProgressBar?.momentId) + (await checkMomentDoneProcessing(momentUploadProgressBar!.momentId)) ) { doneProcessing = true; cancelAnimation(progress); @@ -51,6 +51,7 @@ const MomentUploadProgressBar: React.FC = }); // change status to Done 1s after the progress bar animation is done setTimeout(() => { + dispatch(loadUserMoments(loggedInUserId)); dispatch({ type: setMomentUploadProgressBar.type, payload: { @@ -60,7 +61,7 @@ const MomentUploadProgressBar: React.FC = }, }, }); - }, finishProgressBarDuration + 1000); + }, finishProgressBarDuration); } }; if ( @@ -97,11 +98,10 @@ const MomentUploadProgressBar: React.FC = if ( momentUploadProgressBar?.status === MomentUploadStatusType.UploadingToS3 ) { - // assume it takes video duration (upload) + 1/2 of the video (process) duration to upload - // e.g. 30s video => 30 + 30 * .5 = 37.5s + // e.g. 30s video => 30 * 2 = 60s const videoDuration = momentUploadProgressBar.originalVideoDuration ?? 30; - const durationInSeconds = videoDuration * 1.5; + const durationInSeconds = videoDuration * 2; progress.value = withTiming(1, { duration: durationInSeconds * 1000, easing: Easing.out(Easing.quad), @@ -117,9 +117,6 @@ const MomentUploadProgressBar: React.FC = progress.value = 0; // clear this component after a duration setTimeout(() => { - if (momentUploadProgressBar?.status === MomentUploadStatusType.Done) { - dispatch(loadUserMoments(loggedInUserId)); - } dispatch({ type: setMomentUploadProgressBar.type, payload: { -- cgit v1.2.3-70-g09d2