aboutsummaryrefslogtreecommitdiff
path: root/src/components
diff options
context:
space:
mode:
Diffstat (limited to 'src/components')
-rw-r--r--src/components/moments/Moment.tsx60
-rw-r--r--src/components/moments/MomentPostContent.tsx37
2 files changed, 40 insertions, 57 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);
}
}),
},
diff --git a/src/components/moments/MomentPostContent.tsx b/src/components/moments/MomentPostContent.tsx
index 27a68e47..8615a332 100644
--- a/src/components/moments/MomentPostContent.tsx
+++ b/src/components/moments/MomentPostContent.tsx
@@ -82,7 +82,6 @@ const MomentPostContent: React.FC<MomentPostContentProps> = ({
setHideText(false);
}
}, [keyboardVisible, hideText]);
-
return (
<View style={[styles.container, style]}>
<TouchableWithoutFeedback
@@ -91,23 +90,25 @@ const MomentPostContent: React.FC<MomentPostContentProps> = ({
setFadeValue(new Animated.Value(0));
}}>
{isVideo ? (
- <Video
- // ref={imageRef}
- source={{
- uri: moment.moment_url,
- }}
- // HLS m3u8 version
- // source={{
- // uri: 'https://multiplatform-f.akamaihd.net/i/multi/will/bunny/big_buck_bunny_,640x360_400,640x360_700,640x360_1000,950x540_1500,.f4v.csmil/master.m3u8',
- // }}
- // mp4 version
- // source={{
- // uri: 'http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4',
- // }}
- volume={1}
- style={styles.image}
- // style={styles.video}
- />
+ <View ref={imageRef}>
+ <Video
+ // ref={imageRef}
+ source={{
+ uri: moment.moment_url,
+ }}
+ // HLS m3u8 version
+ // source={{
+ // uri: 'https://multiplatform-f.akamaihd.net/i/multi/will/bunny/big_buck_bunny_,640x360_400,640x360_700,640x360_1000,950x540_1500,.f4v.csmil/master.m3u8',
+ // }}
+ // mp4 version
+ // source={{
+ // uri: 'http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4',
+ // }}
+ volume={1}
+ style={styles.image}
+ repeat={true}
+ />
+ </View>
) : (
<Image
ref={imageRef}