From d518a5e7ae053ef55ca4ede254586f77be86e768 Mon Sep 17 00:00:00 2001 From: Ivan Chen Date: Wed, 21 Jul 2021 19:19:30 -0400 Subject: Add service, Add logic for checking upload finished --- src/components/moments/MomentUploadProgressBar.tsx | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'src/components') diff --git a/src/components/moments/MomentUploadProgressBar.tsx b/src/components/moments/MomentUploadProgressBar.tsx index 28fbd8cb..0d84236d 100644 --- a/src/components/moments/MomentUploadProgressBar.tsx +++ b/src/components/moments/MomentUploadProgressBar.tsx @@ -4,6 +4,7 @@ import {View} from 'react-native-animatable'; import {Easing, useSharedValue, withTiming} from 'react-native-reanimated'; import {SafeAreaView} from 'react-native-safe-area-context'; import {useSelector} from 'react-redux'; +import {checkMomentUploadFinished} from '../../services'; import {RootState} from '../../store/rootReducer'; import {MomentUploadStatusType} from '../../types'; import {normalize, SCREEN_WIDTH, StatusBarHeight} from '../../utils'; @@ -18,6 +19,21 @@ const MomentUploadProgressBar: React.FC = ); const progress = useSharedValue(0); + useEffect(() => { + if ( + momentUploadProgressBar?.status === MomentUploadStatusType.Uploading + ) { + const timer = setInterval(async () => { + if (checkMomentUploadFinished(momentUploadProgressBar.momentId)) { + // call upload finished action + } + }, 5 * 1000); + setTimeout(() => { + clearInterval(timer); + }, 5 * 60 * 1000); + } + }, []); + useEffect(() => { if ( momentUploadProgressBar?.status === MomentUploadStatusType.Uploading -- cgit v1.2.3-70-g09d2