diff options
| author | Ivan Chen <ivan@tagg.id> | 2021-06-23 17:49:46 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-06-23 17:49:46 -0400 |
| commit | 981051448fee6197544383e535fea7a72827d41d (patch) | |
| tree | 10015427c4c62a1dbf73cad4dfd0ee2dd43b110c /src/components/moments/Moment.tsx | |
| parent | 8c2b915678b852f597c38ab00d18c22bf62d2051 (diff) | |
| parent | f9a3acb40dd224591f8e7039e84e428d4363a841 (diff) | |
Merge pull request #474 from IvanIFChen/tma944-video-moment-userflow
[TMA-944] Share Video Moment User Flow
Diffstat (limited to 'src/components/moments/Moment.tsx')
| -rw-r--r-- | src/components/moments/Moment.tsx | 60 |
1 files changed, 21 insertions, 39 deletions
diff --git a/src/components/moments/Moment.tsx b/src/components/moments/Moment.tsx index e4acebdf..eab4b7e3 100644 --- a/src/components/moments/Moment.tsx +++ b/src/components/moments/Moment.tsx @@ -5,7 +5,6 @@ import {Text} from 'react-native-animatable'; import {ScrollView, TouchableOpacity} from 'react-native-gesture-handler'; import ImagePicker from 'react-native-image-crop-picker'; import LinearGradient from 'react-native-linear-gradient'; -import {useDispatch, useSelector} from 'react-redux'; import DeleteIcon from '../../assets/icons/delete-logo.svg'; import DownIcon from '../../assets/icons/down_icon.svg'; import BigPlusIcon from '../../assets/icons/plus-icon-white.svg'; @@ -13,12 +12,6 @@ import PlusIcon from '../../assets/icons/plus-icon.svg'; import UpIcon from '../../assets/icons/up_icon.svg'; import {TAGG_LIGHT_BLUE} from '../../constants'; import {ERROR_UPLOAD} from '../../constants/strings'; -import { - handlePresignedURL, - handleVideoUpload, -} from '../../services/MomentService'; -import {loadUserMoments} from '../../store/actions'; -import {RootState} from '../../store/rootReducer'; import {MomentType, ScreenType} from '../../types'; import {normalize, SCREEN_WIDTH} from '../../utils'; import MomentTile from './MomentTile'; @@ -49,22 +42,18 @@ const Moment: React.FC<MomentProps> = ({ externalStyles, }) => { const navigation = useNavigation(); - const dispatch = useDispatch(); - const { - user: {userId}, - } = useSelector((state: RootState) => state.user); - const uploadVideo = async (filePath: string) => { + const navigateToCaptionScreenForVideo = (uri: string) => { const randHash = Math.random().toString(36).substring(7); - const filename = `poc_${randHash}.mov`; - const presignedURL = await handlePresignedURL(filename, title); - if (presignedURL) { - console.log('presigned' + JSON.stringify(presignedURL)); - Alert.alert('Upload begin in background...'); - await handleVideoUpload(filename, filePath, presignedURL); - Alert.alert('Finish uploading, refreshing moments...'); - dispatch(loadUserMoments(userId)); - } + navigation.navigate('CaptionScreen', { + screenType, + title, + media: { + filename: `poc_${randHash}.mov`, + uri, + isVideo: true, + }, + }); }; /** * This function opens the ImagePicker, only lets you select video files, @@ -75,23 +64,12 @@ const Moment: React.FC<MomentProps> = ({ */ const navigateToVideoPicker = () => { ImagePicker.openPicker({ - smartAlbums: [ - 'Favorites', - 'RecentlyAdded', - 'SelfPortraits', - 'Screenshots', - 'UserLibrary', - ], - cropperToolbarTitle: 'select a video', mediaType: 'video', }) .then(async (vid) => { - if ('path' in vid) { - console.log(vid); - // vid.path is compressed mp4, vid.sourceURL is uncompressed original - if (vid.path) { - uploadVideo(vid.path); - } + console.log(vid); + if (vid.path) { + navigateToCaptionScreenForVideo(vid.path); } }) .catch((err) => { @@ -117,11 +95,15 @@ const Moment: React.FC<MomentProps> = ({ mediaType: 'photo', }) .then((picture) => { - if ('path' in picture) { + if (picture.path && picture.filename) { navigation.navigate('CaptionScreen', { screenType, - title: title, - image: picture, + title, + media: { + filename: picture.filename, + uri: picture.path, + isVideo: false, + }, }); } }) @@ -182,7 +164,7 @@ const Moment: React.FC<MomentProps> = ({ }).then((vid) => { console.log(vid); if (vid.path) { - uploadVideo(vid.path); + navigateToCaptionScreenForVideo(vid.path); } }), }, |
