diff options
author | Ivan Chen <ivan@tagg.id> | 2021-06-22 18:36:47 -0400 |
---|---|---|
committer | Ivan Chen <ivan@tagg.id> | 2021-06-22 18:36:47 -0400 |
commit | ee890e517dd3688a4fd63c64592fdb6ce683d7b4 (patch) | |
tree | 7898bb80e497c509dd492419cf557592b5cb0597 | |
parent | cd5863264d0fe954e63d8cc93fc4ee6ab509f49b (diff) |
Improve poc UX
-rw-r--r-- | src/components/moments/Moment.tsx | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/src/components/moments/Moment.tsx b/src/components/moments/Moment.tsx index 34b2c7ea..9bce6c74 100644 --- a/src/components/moments/Moment.tsx +++ b/src/components/moments/Moment.tsx @@ -5,6 +5,7 @@ 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'; @@ -16,6 +17,8 @@ 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'; @@ -46,6 +49,10 @@ const Moment: React.FC<MomentProps> = ({ externalStyles, }) => { const navigation = useNavigation(); + const dispatch = useDispatch(); + const { + user: {userId}, + } = useSelector((state: RootState) => state.user); /** * This function opens the ImagePicker, only lets you select video files, * formats the file extension, then makes a call to the server to get the presigned URL, @@ -62,21 +69,19 @@ const Moment: React.FC<MomentProps> = ({ 'Screenshots', 'UserLibrary', ], - width: 580, - height: 580, - cropping: false, cropperToolbarTitle: 'select a video', mediaType: 'video', }) .then(async (vid) => { if ('path' in vid) { - let fileName = vid.filename || ''; - if (fileName.endsWith('.heic') || fileName.endsWith('.HEIC')) { - fileName = fileName.split('.')[0] + '.jpg'; + if (vid.filename) { + let presignedURL = await handlePresignedURL(vid.filename, title); + console.log('presigned' + JSON.stringify(presignedURL)); + Alert.alert('Uploading...'); + await handleVideoUpload(vid, presignedURL); + Alert.alert('Finish uploading, refreshing moments...'); + dispatch(loadUserMoments(userId)); } - let presignedURL = await handlePresignedURL(fileName, title); - console.log('presigned' + JSON.stringify(presignedURL)); - handleVideoUpload(vid, presignedURL); } }) .catch((err) => { |