From 7d57106ae614e42ea1d7d871a098e0acefc83762 Mon Sep 17 00:00:00 2001 From: Ivan Chen Date: Tue, 20 Jul 2021 16:07:36 -0400 Subject: Add progress bar library, Add placeholder component --- src/screens/profile/ProfileScreen.tsx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/screens') diff --git a/src/screens/profile/ProfileScreen.tsx b/src/screens/profile/ProfileScreen.tsx index 3dd142e1..f8e50af1 100644 --- a/src/screens/profile/ProfileScreen.tsx +++ b/src/screens/profile/ProfileScreen.tsx @@ -1,7 +1,7 @@ +import {RouteProp} from '@react-navigation/native'; import React, {useEffect} from 'react'; import {StatusBar} from 'react-native'; -import {Content, TabsGradient} from '../../components'; -import {RouteProp} from '@react-navigation/native'; +import {Content, MomentUploadProgressBar, TabsGradient} from '../../components'; import {MainStackParams} from '../../routes/'; import {visitedUserProfile} from '../../services'; @@ -24,6 +24,7 @@ const ProfileScreen: React.FC = ({route}) => { return ( <> + -- cgit v1.2.3-70-g09d2 From bc82aaf481949d690af814b9dd4a0e9cab387011 Mon Sep 17 00:00:00 2001 From: Ivan Chen Date: Thu, 22 Jul 2021 15:09:39 -0400 Subject: Rename util function, Pass video duration to caption screen --- src/components/camera/GalleryIcon.tsx | 4 ++-- src/components/moments/TrimmerPlayer.tsx | 2 +- src/routes/main/MainStackNavigator.tsx | 2 +- src/screens/upload/EditMedia.tsx | 14 ++++++++++---- src/store/reducers/userReducer.ts | 5 +++++ src/types/types.ts | 2 +- src/utils/camera.ts | 2 +- 7 files changed, 21 insertions(+), 10 deletions(-) (limited to 'src/screens') diff --git a/src/components/camera/GalleryIcon.tsx b/src/components/camera/GalleryIcon.tsx index ca2d2559..44297d6d 100644 --- a/src/components/camera/GalleryIcon.tsx +++ b/src/components/camera/GalleryIcon.tsx @@ -1,6 +1,6 @@ import React from 'react'; import {Image, Text, TouchableOpacity, View} from 'react-native'; -import {navigateToImagePicker} from '../../utils/camera'; +import {navigateToMediaPicker} from '../../utils/camera'; import {ImageOrVideo} from 'react-native-image-crop-picker'; import {styles} from './styles'; @@ -19,7 +19,7 @@ export const GalleryIcon: React.FC = ({ }) => { return ( navigateToImagePicker(callback)} + onPress={() => navigateToMediaPicker(callback)} style={styles.saveButton}> {mostRecentPhotoUri !== '' ? ( = ({ repeat={true} onLoad={(payload) => { setEnd(payload.duration); - handleLoad(payload.naturalSize); + handleLoad(payload.naturalSize, payload.duration); }} onProgress={(e) => { if (!paused) { diff --git a/src/routes/main/MainStackNavigator.tsx b/src/routes/main/MainStackNavigator.tsx index 11e9d08d..585980b5 100644 --- a/src/routes/main/MainStackNavigator.tsx +++ b/src/routes/main/MainStackNavigator.tsx @@ -46,7 +46,7 @@ export type MainStackParams = { }; CaptionScreen: { screenType: ScreenType; - media?: {uri: string; isVideo: boolean}; + media?: {uri: string; isVideo: boolean; videoDuration: number | undefined}; selectedCategory?: string; selectedTags?: MomentTagType[]; moment?: MomentType; diff --git a/src/screens/upload/EditMedia.tsx b/src/screens/upload/EditMedia.tsx index 1dc408ee..38450337 100644 --- a/src/screens/upload/EditMedia.tsx +++ b/src/screens/upload/EditMedia.tsx @@ -43,6 +43,7 @@ export const EditMedia: React.FC = ({route, navigation}) => { const vidRef = useRef(null); const [cropLoading, setCropLoading] = useState(false); const [hideTrimmer, setHideTrimmer] = useState(true); + const [videoDuration, setVideoDuration] = useState(); // Stores the coordinates of the cropped image const [x0, setX0] = useState(); @@ -139,7 +140,7 @@ export const EditMedia: React.FC = ({route, navigation}) => { mediaUri, (croppedURL: string) => { setCropLoading(false); - // Pass the trimmed/cropped video + // Pass the cropped video callback(croppedURL); }, videoCrop, @@ -334,8 +335,12 @@ export const EditMedia: React.FC = ({route, navigation}) => { height: SCREEN_WIDTH / aspectRatio, }, ]} - handleLoad={(response: {width: number; height: number}) => { + handleLoad={( + response: {width: number; height: number}, + duration: number, + ) => { const {width, height} = response; + setVideoDuration(duration); setOrigDimensions([width, height]); setAspectRatio(width / height); }} @@ -383,8 +388,9 @@ export const EditMedia: React.FC = ({route, navigation}) => { navigation.navigate('CaptionScreen', { screenType, media: { - uri: uri, - isVideo: isVideo, + uri, + isVideo, + videoDuration, }, selectedCategory, }), diff --git a/src/store/reducers/userReducer.ts b/src/store/reducers/userReducer.ts index 4692c5d3..617c60be 100644 --- a/src/store/reducers/userReducer.ts +++ b/src/store/reducers/userReducer.ts @@ -85,6 +85,10 @@ const userDataSlice = createSlice({ state.avatar = ''; state.cover = ''; }, + + setMomentUploadProgressBar: (state, action) => { + state.momentUploadProgressBar = action.payload.momentUploadProgressBar; + }, }, }); @@ -102,5 +106,6 @@ export const { clearHeaderAndProfileImages, profileBadgesUpdated, profileBadgeRemoved, + setMomentUploadProgressBar, } = userDataSlice.actions; export const userDataReducer = userDataSlice.reducer; diff --git a/src/types/types.ts b/src/types/types.ts index 2001426a..34bf73ac 100644 --- a/src/types/types.ts +++ b/src/types/types.ts @@ -63,8 +63,8 @@ export interface ProfileInfoType { export interface MomentUploadProgressBarType { status: MomentUploadStatusType; - originalVideoDuration: number; momentId: string; + originalVideoDuration: number | undefined; } export enum MomentUploadStatusType { diff --git a/src/utils/camera.ts b/src/utils/camera.ts index 9d7ff67f..97592fe5 100644 --- a/src/utils/camera.ts +++ b/src/utils/camera.ts @@ -57,7 +57,7 @@ export const saveImageToGallery = ( .catch((_err) => Alert.alert('Failed to save to device!')); }; -export const navigateToImagePicker = ( +export const navigateToMediaPicker = ( callback: (media: ImageOrVideo) => void, ) => { ImagePicker.openPicker({ -- cgit v1.2.3-70-g09d2 From 848204d684f6dfb8ada0856a50487d00ad2c77df Mon Sep 17 00:00:00 2001 From: Ivan Chen Date: Thu, 22 Jul 2021 16:08:45 -0400 Subject: Add action for handling all video uploads --- src/screens/profile/CaptionScreen.tsx | 39 ++++++++------ src/store/actions/user.ts | 98 ++++++++++++++++++++++++++++++++++- src/store/initialStates.ts | 1 - src/types/types.ts | 3 +- 4 files changed, 120 insertions(+), 21 deletions(-) (limited to 'src/screens') 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 = ({route, navigation}) => { const [tags, setTags] = useState([]); const [taggedUsersText, setTaggedUsersText] = useState(''); const [momentCategory, setMomentCategory] = useState(); + // 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 = ({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 = ({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) { diff --git a/src/store/actions/user.ts b/src/store/actions/user.ts index b1cb8719..1acbb519 100644 --- a/src/store/actions/user.ts +++ b/src/store/actions/user.ts @@ -1,13 +1,21 @@ import AsyncStorage from '@react-native-community/async-storage'; -import {StreamChat} from 'stream-chat'; import {Action, ThunkAction} from '@reduxjs/toolkit'; +import {StreamChat} from 'stream-chat'; import { getProfilePic, + handlePresignedURL, + handleVideoUpload, loadProfileInfo, + postMomentTags, removeBadgesService, sendSuggestedPeopleLinked, } from '../../services'; -import {UniversityBadge, UserType} from '../../types/types'; +import { + MomentUploadProgressBarType, + MomentUploadStatusType, + UniversityBadge, + UserType, +} from '../../types/types'; import {getTokenOrLogout} from '../../utils'; import { clearHeaderAndProfileImages, @@ -15,6 +23,7 @@ import { profileBadgesUpdated, profileCompletionStageUpdated, setIsOnboardedUser, + setMomentUploadProgressBar, setNewNotificationReceived, setNewVersionAvailable, setReplyPosted, @@ -275,3 +284,88 @@ export const suggestedPeopleAnimatedTutorialFinished = ); } }; + +/** + * state is now UploadingToS3: + * - get presigned url (backend creates the moment object) + * - upload moment tags + * - upload video to s3 + * state is now WaitingForDoneProcessing + */ +export const handleVideoMomentUpload = + ( + videoUri: string, + videoLength: number, + momentCategory: string, + formattedTags: { + x: number; + y: number; + z: number; + user_id: string; + }[], + ): ThunkAction, RootState, unknown, Action> => + async (dispatch) => { + try { + const handleError = (reason: string) => { + console.error('Moment video upload failed,', reason); + dispatch({ + type: setMomentUploadProgressBar.type, + payload: { + momentUploadProgressBar: { + ...momentUploadProgressBar, + status: MomentUploadStatusType.Error, + }, + }, + }); + }; + let momentUploadProgressBar: MomentUploadProgressBarType = { + status: MomentUploadStatusType.UploadingToS3, + momentId: '', + originalVideoDuration: videoLength, + }; + // set progress bar as loading + dispatch({ + type: setMomentUploadProgressBar.type, + payload: {momentUploadProgressBar}, + }); + // get a presigned url for the video + const presignedURLResponse = await handlePresignedURL(momentCategory); + if (!presignedURLResponse) { + handleError('Presigned URL failed'); + return; + } + const momentId = presignedURLResponse.moment_id; + const fileHash = presignedURLResponse.response_url.fields.key; + // upload moment tags, now that we have a moment id + const momentTagResponse = await postMomentTags(momentId, formattedTags); + if (!momentTagResponse) { + handleError('Upload moment tags failed'); + return; + } + if (!fileHash) { + handleError('Unable to parse file hash from presigned response'); + return; + } + // upload video to s3 + const videoUploadResponse = await handleVideoUpload( + videoUri, + presignedURLResponse, + ); + if (!videoUploadResponse) { + handleError('Video upload failed'); + return; + } + dispatch({ + type: setMomentUploadProgressBar.type, + payload: { + momentUploadProgressBar: { + ...momentUploadProgressBar, + status: MomentUploadStatusType.WaitingForDoneProcessing, + momentId, + }, + }, + }); + } catch (error) { + console.log(error); + } + }; diff --git a/src/store/initialStates.ts b/src/store/initialStates.ts index ddfdf5d2..7d8cf439 100644 --- a/src/store/initialStates.ts +++ b/src/store/initialStates.ts @@ -11,7 +11,6 @@ import { CommentThreadType, MomentPostType, MomentUploadProgressBarType, - MomentUploadStatusType, UniversityType, } from './../types/types'; diff --git a/src/types/types.ts b/src/types/types.ts index 34bf73ac..685e3784 100644 --- a/src/types/types.ts +++ b/src/types/types.ts @@ -68,7 +68,8 @@ export interface MomentUploadProgressBarType { } export enum MomentUploadStatusType { - Uploading = 'Uploading', + UploadingToS3 = 'UploadingToS3', + WaitingForDoneProcessing = 'WaitingForDoneProcessing', Done = 'Done', Error = 'Error', } -- cgit v1.2.3-70-g09d2 From 8181eacc003342fc6bff649b8d1bd793a88efee5 Mon Sep 17 00:00:00 2001 From: Ivan Chen Date: Thu, 22 Jul 2021 18:13:08 -0400 Subject: Handle error case for displaying alert, Add logic to auto reload --- src/components/moments/MomentUploadProgressBar.tsx | 25 ++++++++++++++-------- src/routes/main/MainStackNavigator.tsx | 1 + src/screens/profile/CaptionScreen.tsx | 16 ++++---------- 3 files changed, 21 insertions(+), 21 deletions(-) (limited to 'src/screens') diff --git a/src/components/moments/MomentUploadProgressBar.tsx b/src/components/moments/MomentUploadProgressBar.tsx index 742c403b..afda16e2 100644 --- a/src/components/moments/MomentUploadProgressBar.tsx +++ b/src/components/moments/MomentUploadProgressBar.tsx @@ -10,6 +10,7 @@ import { import {SafeAreaView} from 'react-native-safe-area-context'; import {useDispatch, useSelector} from 'react-redux'; import {checkMomentUploadFinished} from '../../services'; +import {loadUserMoments} from '../../store/actions'; import {setMomentUploadProgressBar} from '../../store/reducers'; import {RootState} from '../../store/rootReducer'; import {MomentUploadStatusType} from '../../types'; @@ -21,6 +22,9 @@ interface MomentUploadProgressBarProps {} const MomentUploadProgressBar: React.FC = ({}) => { const dispatch = useDispatch(); + const {userId: loggedInUserId} = useSelector( + (state: RootState) => state.user.user, + ); const {momentUploadProgressBar} = useSelector( (state: RootState) => state.user, ); @@ -72,17 +76,19 @@ const MomentUploadProgressBar: React.FC = }, 5 * 1000); // timeout if takes longer than 1 minute to process setTimeout(() => { - console.error('Check for done processing timed out'); clearInterval(timer); - dispatch({ - type: setMomentUploadProgressBar.type, - payload: { - momentUploadProgressBar: { - ...momentUploadProgressBar, - status: MomentUploadStatusType.Error, + if (!doneProcessing) { + console.error('Check for done processing timed out'); + dispatch({ + type: setMomentUploadProgressBar.type, + payload: { + momentUploadProgressBar: { + ...momentUploadProgressBar, + status: MomentUploadStatusType.Error, + }, }, - }, - }); + }); + } }, 60 * 1000); return () => clearInterval(timer); } @@ -109,6 +115,7 @@ const MomentUploadProgressBar: React.FC = progress.value = 0; // clear this component after a duration setTimeout(() => { + dispatch(loadUserMoments(loggedInUserId)); dispatch({ type: setMomentUploadProgressBar.type, payload: { diff --git a/src/routes/main/MainStackNavigator.tsx b/src/routes/main/MainStackNavigator.tsx index 585980b5..8def19e3 100644 --- a/src/routes/main/MainStackNavigator.tsx +++ b/src/routes/main/MainStackNavigator.tsx @@ -58,6 +58,7 @@ export type MainStackParams = { media: { uri: string; isVideo: boolean; + videoDuration: number | undefined; }; selectedTags?: MomentTagType[]; }; diff --git a/src/screens/profile/CaptionScreen.tsx b/src/screens/profile/CaptionScreen.tsx index 88ff0ecc..6ba1791c 100644 --- a/src/screens/profile/CaptionScreen.tsx +++ b/src/screens/profile/CaptionScreen.tsx @@ -34,13 +34,7 @@ import { } from '../../constants/strings'; import * as RootNavigation from '../../RootNavigation'; import {MainStackParams} from '../../routes'; -import { - handlePresignedURL, - handleVideoUpload, - patchMoment, - postMoment, - postMomentTags, -} from '../../services'; +import {patchMoment, postMoment, postMomentTags} from '../../services'; import { handleVideoMomentUpload, loadUserMoments, @@ -136,11 +130,7 @@ const CaptionScreen: React.FC = ({route, navigation}) => { navigation.popToTop(); RootNavigation.navigate('ProfileTab'); setTimeout(() => { - if (isMediaAVideo) { - Alert.alert( - 'Beautiful, the Moment was uploaded successfully! Check back in a bit and refresh to see it!', - ); - } else { + if (!isMediaAVideo) { Alert.alert(SUCCESS_PIC_UPLOAD); } }, 500); @@ -182,6 +172,7 @@ const CaptionScreen: React.FC = ({route, navigation}) => { ); } else { handleFailed(); + return; } } else { const momentResponse = await postMoment( @@ -330,6 +321,7 @@ const CaptionScreen: React.FC = ({route, navigation}) => { media: { uri: mediaUri, isVideo: isMediaAVideo, + videoDuration, }, selectedTags: tags, }) -- cgit v1.2.3-70-g09d2 From 4f68cb3f7280222223ccc2ad086125f113660921 Mon Sep 17 00:00:00 2001 From: Ivan Chen Date: Thu, 22 Jul 2021 18:32:13 -0400 Subject: Made progress bar non-stick to top --- src/components/profile/Content.tsx | 2 ++ src/screens/profile/ProfileScreen.tsx | 3 +-- 2 files changed, 3 insertions(+), 2 deletions(-) (limited to 'src/screens') diff --git a/src/components/profile/Content.tsx b/src/components/profile/Content.tsx index 2d1002dd..9edd890d 100644 --- a/src/components/profile/Content.tsx +++ b/src/components/profile/Content.tsx @@ -6,6 +6,7 @@ import Animated, { useSharedValue, } from 'react-native-reanimated'; import {useDispatch, useSelector, useStore} from 'react-redux'; +import {MomentUploadProgressBar} from '..'; import { blockUnblockUser, loadFriendsData, @@ -140,6 +141,7 @@ const Content: React.FC = ({userXId, screenType}) => { refreshControl={ }> + {!userXId && } = ({route}) => { return ( <> - -- cgit v1.2.3-70-g09d2 From e3302c00072ab8275ccd01f58037fcadf54a9614 Mon Sep 17 00:00:00 2001 From: Ivan Chen Date: Fri, 23 Jul 2021 15:08:53 -0400 Subject: Add check to prevent multiple uploads --- src/constants/strings.ts | 13 +++++------ src/screens/upload/EditMedia.tsx | 47 ++++++++++++++++++++++++++++------------ 2 files changed, 39 insertions(+), 21 deletions(-) (limited to 'src/screens') diff --git a/src/constants/strings.ts b/src/constants/strings.ts index 071b3835..450d7e5c 100644 --- a/src/constants/strings.ts +++ b/src/constants/strings.ts @@ -2,8 +2,8 @@ // Below is the regex to convert this into a csv for the Google Sheet // export const (.*) = .*?(['|"|`])(.*)\2; // replace with: $1\t$3 -export const APP_STORE_LINK = 'https://apps.apple.com/us/app/tagg-discover-your-community/id1537853613' export const ADD_COMMENT_TEXT = (username?: string) => username ? `Reply to ${username}` : 'Add a comment...' +export const APP_STORE_LINK = 'https://apps.apple.com/us/app/tagg-discover-your-community/id1537853613' export const COMING_SOON_MSG = 'Creating more fun things for you, surprises coming soon πŸ˜‰'; export const ERROR_ATTEMPT_EDIT_SP = 'Can\'t let you do that yet! Please onboard Suggested People first!'; export const ERROR_AUTHENTICATION = 'An error occurred during authentication. Please login again!'; @@ -31,8 +31,10 @@ export const ERROR_INVLAID_CODE = 'The code entered is not valid!'; export const ERROR_LINK = (str: string) => `Unable to link with ${str}, Please check your login and try again`; export const ERROR_LOGIN = 'There was a problem logging you in, please refresh and try again'; export const ERROR_LOGIN_FAILED = 'Login failed. Check your username and password, and try again'; +export const ERROR_MOMENT_UPLOAD_IN_PROGRESS = 'Please wait, there is a Moment upload in progress.'; export const ERROR_NEXT_PAGE = 'There was a problem while loading the next page πŸ˜“, try again in a couple minutes'; export const ERROR_NO_CONTACT_INVITE_LEFT = 'You have no more invites left!' +export const ERROR_NO_MOMENT_CATEGORY = 'Please select a category!'; export const ERROR_NOT_ONBOARDED = 'You are now on waitlist, please enter your invitation code if you have one'; export const ERROR_PHONE_IN_USE = 'Phone already in use, please try another one'; export const ERROR_PROFILE_CREATION_SHORT = 'Profile creation failed πŸ˜“'; @@ -45,7 +47,6 @@ export const ERROR_SELECT_GENDER = 'Please select your gender'; export const ERROR_SELECT_UNIVERSITY = 'Please select your University'; export const ERROR_SERVER_DOWN = 'mhm, looks like our servers are down, please refresh and try again in a few mins'; export const ERROR_SOMETHING_WENT_WRONG = 'Oh dear, don’t worry someone will be held responsible for this error, In the meantime refresh the app'; -export const ERROR_NO_MOMENT_CATEGORY = 'Please select a category!'; export const ERROR_SOMETHING_WENT_WRONG_REFRESH = "Ha, looks like this one's on us, please refresh and try again"; export const ERROR_SOMETHING_WENT_WRONG_RELOAD = "You broke it, Just kidding! we don't know what happened... Please reload the app and try again"; export const ERROR_T_AND_C_NOT_ACCEPTED = 'You must first agree to the terms and conditions.'; @@ -61,6 +62,7 @@ export const ERROR_UPLOAD_SMALL_PROFILE_PIC = "Can't have a profile without a pi export const ERROR_UPLOAD_SP_PHOTO = 'Unable to update suggested people photo. Please retry!'; export const ERROR_VERIFICATION_FAILED_SHORT = 'Verification failed πŸ˜“'; export const FIRST_MESSAGE = 'How about sending your first message to your friend'; +export const INVITE_USER_SMS_BODY = (invitedUserName: string, invitee: string, inviteCode: string) => `Hey ${invitedUserName}!\nYou've been tagged by ${invitee}. Follow the instructions below to skip the line and join them on Tagg!\nSign up and use this code to get in: ${inviteCode}\n ${APP_STORE_LINK}`; export const MARKED_AS_MSG = (str: string) => `Marked as ${str}`; export const MOMENT_DELETED_MSG = 'Moment deleted....Some moments have to go, to create space for greater ones'; export const NO_NEW_NOTIFICATIONS = 'You have no new notifications'; @@ -69,13 +71,10 @@ export const PRIVATE_ACCOUNT = 'This account is private'; export const START_CHATTING = 'Let’s Start Chatting!'; export const SUCCESS_BADGES_UPDATE = 'Badges updated successfully!' export const SUCCESS_CATEGORY_DELETE = 'Category successfully deleted, but its memory will live on'; +export const SUCCESS_CONFIRM_INVITE_CONTACT_MESSAGE = 'Use one now?'; +export const SUCCESS_CONFIRM_INVITE_CONTACT_TITLE = (str: string) => `You have ${str} invites left!`; export const SUCCESS_INVITATION_CODE = 'Welcome to Tagg!'; export const SUCCESS_INVITE_CONTACT = (str: string) => `Success! You now have ${str} invites left!`; -export const SUCCESS_CONFIRM_INVITE_CONTACT_TITLE = (str: string) => `You have ${str} invites left!`; -export const SUCCESS_CONFIRM_INVITE_CONTACT_MESSAGE = 'Use one now?'; -export const INVITE_USER_SMS_BODY = (invitedUserName: string, invitee: string, inviteCode: string) => `Hey ${invitedUserName}!\n -You've been tagged by ${invitee}. Follow the instructions below to skip the line and join them on Tagg!\n -Sign up and use this code to get in: ${inviteCode}\n ${APP_STORE_LINK}`; export const SUCCESS_LAST_CONTACT_INVITE = 'Done! That was your last invite, hope you used it wisely!'; export const SUCCESS_LINK = (str: string) => `Successfully linked ${str} πŸŽ‰`; export const SUCCESS_PIC_UPLOAD = 'Beautiful, the Moment was uploaded successfully!'; diff --git a/src/screens/upload/EditMedia.tsx b/src/screens/upload/EditMedia.tsx index 9a061a53..07d20a7b 100644 --- a/src/screens/upload/EditMedia.tsx +++ b/src/screens/upload/EditMedia.tsx @@ -2,14 +2,24 @@ import ReactNativeZoomableView from '@dudigital/react-native-zoomable-view/src/R import {RouteProp} from '@react-navigation/core'; import {StackNavigationProp} from '@react-navigation/stack'; import React, {useEffect, useRef, useState} from 'react'; -import {Image, StyleSheet, Text, TouchableOpacity, View} from 'react-native'; +import { + Alert, + Image, + StyleSheet, + Text, + TouchableOpacity, + View, +} from 'react-native'; import ImageZoom, {IOnMove} from 'react-native-image-pan-zoom'; import PhotoManipulator from 'react-native-photo-manipulator'; +import {useSelector} from 'react-redux'; import TrimIcon from '../../assets/icons/trim.svg'; import CloseIcon from '../../assets/ionicons/close-outline.svg'; import {SaveButton, TrimmerPlayer} from '../../components'; import {TaggLoadingIndicator, TaggSquareButton} from '../../components/common'; +import {ERROR_MOMENT_UPLOAD_IN_PROGRESS} from '../../constants/strings'; import {MainStackParams} from '../../routes'; +import {RootState} from '../../store/rootReducer'; import { cropVideo, HeaderHeight, @@ -36,6 +46,9 @@ export const EditMedia: React.FC = ({route, navigation}) => { selectedCategory, media: {isVideo}, } = route.params; + const {momentUploadProgressBar} = useSelector( + (state: RootState) => state.user, + ); const [aspectRatio, setAspectRatio] = useState(1); // width and height of video, if video const [origDimensions, setOrigDimensions] = useState([0, 0]); @@ -252,6 +265,24 @@ export const EditMedia: React.FC = ({route, navigation}) => { ); }; + const handleNext = () => { + if (momentUploadProgressBar) { + Alert.alert(ERROR_MOMENT_UPLOAD_IN_PROGRESS); + } else { + processVideo((uri) => + navigation.navigate('CaptionScreen', { + screenType, + media: { + uri, + isVideo, + videoDuration, + }, + selectedCategory, + }), + ); + } + }; + return ( {cropLoading && } @@ -391,19 +422,7 @@ export const EditMedia: React.FC = ({route, navigation}) => { /> - processVideo((uri) => - navigation.navigate('CaptionScreen', { - screenType, - media: { - uri, - isVideo, - videoDuration, - }, - selectedCategory, - }), - ) - } + onPress={handleNext} title={'Next'} buttonStyle={'large'} buttonColor={'blue'} -- cgit v1.2.3-70-g09d2