From 9b94f60df0b62a9d3762a1963ec7dac024658a51 Mon Sep 17 00:00:00 2001 From: Ivan Chen Date: Wed, 21 Jul 2021 19:11:32 -0400 Subject: Update progress bar type --- src/components/moments/MomentUploadProgressBar.tsx | 16 +++++++++++----- src/constants/api.ts | 1 + src/store/initialStates.ts | 3 ++- src/types/types.ts | 7 ++++++- 4 files changed, 20 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/components/moments/MomentUploadProgressBar.tsx b/src/components/moments/MomentUploadProgressBar.tsx index 285f4e84..07d876e8 100644 --- a/src/components/moments/MomentUploadProgressBar.tsx +++ b/src/components/moments/MomentUploadProgressBar.tsx @@ -13,17 +13,23 @@ interface MomentUploadProgressBarProps {} const MomentUploadProgressBar: React.FC = ({}) => { - const {momentUploadStatus} = useSelector((state: RootState) => state.user); - const progress = useSharedValue(0); + const {momentUploadProgressBar} = useSelector( + (state: RootState) => state.user, + ); + const progress = useSharedValue(0.001); useEffect(() => { - if (momentUploadStatus === MomentUploadStatusType.Uploading) { + if ( + momentUploadProgressBar?.status === MomentUploadStatusType.Uploading + ) { progress.value = withTiming(1, { - duration: 30 * 1000, + duration: momentUploadProgressBar.originalVideoDuration * 1000, easing: Easing.out(Easing.quad), }); } - }, [momentUploadStatus]); + }, [momentUploadProgressBar?.status]); + + useEffect(() => {}, []); return ( diff --git a/src/constants/api.ts b/src/constants/api.ts index 6dab1153..ec2f0897 100644 --- a/src/constants/api.ts +++ b/src/constants/api.ts @@ -39,6 +39,7 @@ export const COMMENTS_ENDPOINT: string = API_URL + 'comments/'; export const COMMENT_REACTIONS_ENDPOINT: string = API_URL + 'reaction-comment/'; export const COMMENT_REACTIONS_REPLY_ENDPOINT: string = API_URL + 'reaction-reply/'; export const PRESIGNED_URL_ENDPOINT: string = API_URL + 'presigned-url/'; +export const CHECK_MOMENT_UPLOAD_FINISHED_ENDPOINT: string = API_URL + 'moments/check_upload_finished/'; export const FRIENDS_ENDPOINT: string = API_URL + 'friends/'; export const ALL_USERS_ENDPOINT: string = API_URL + 'users/'; export const REPORT_ISSUE_ENDPOINT: string = API_URL + 'report/'; diff --git a/src/store/initialStates.ts b/src/store/initialStates.ts index 5ae62838..ddfdf5d2 100644 --- a/src/store/initialStates.ts +++ b/src/store/initialStates.ts @@ -10,6 +10,7 @@ import { import { CommentThreadType, MomentPostType, + MomentUploadProgressBarType, MomentUploadStatusType, UniversityType, } from './../types/types'; @@ -49,7 +50,7 @@ export const NO_USER_DATA = { profile: NO_PROFILE, avatar: undefined, cover: undefined, - momentUploadStatus: MomentUploadStatusType.Empty, + momentUploadProgressBar: undefined, isOnboardedUser: false, newVersionAvailable: false, newNotificationReceived: false, diff --git a/src/types/types.ts b/src/types/types.ts index 930f833b..2001426a 100644 --- a/src/types/types.ts +++ b/src/types/types.ts @@ -61,8 +61,13 @@ export interface ProfileInfoType { is_private: boolean; } +export interface MomentUploadProgressBarType { + status: MomentUploadStatusType; + originalVideoDuration: number; + momentId: string; +} + export enum MomentUploadStatusType { - Empty = 'Empty', Uploading = 'Uploading', Done = 'Done', Error = 'Error', -- cgit v1.2.3-70-g09d2