From 545caa8c32e383551b1f1d5de61a300bc39100ff Mon Sep 17 00:00:00 2001 From: Ivan Chen Date: Wed, 23 Jun 2021 15:21:14 -0400 Subject: Cleanup code, Update route params for Caption Screen --- src/screens/profile/CaptionScreen.tsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/screens/profile/CaptionScreen.tsx') diff --git a/src/screens/profile/CaptionScreen.tsx b/src/screens/profile/CaptionScreen.tsx index 9e1b4674..bb02494d 100644 --- a/src/screens/profile/CaptionScreen.tsx +++ b/src/screens/profile/CaptionScreen.tsx @@ -51,7 +51,7 @@ interface CaptionScreenProps { } const CaptionScreen: React.FC = ({route, navigation}) => { - const {title, image, screenType, selectedTags, moment} = route.params; + const {title, media, screenType, selectedTags, moment} = route.params; const { user: {userId}, } = useSelector((state: RootState) => state.user); @@ -120,12 +120,12 @@ const CaptionScreen: React.FC = ({route, navigation}) => { const handleShare = async () => { setLoading(true); - if (!image?.filename || !title) { + if (!media || !title) { return; } const momentResponse = await postMoment( - image.filename, - image.path, + media.filename, + media.uri, caption, title, userId, -- cgit v1.2.3-70-g09d2 From 205475150e32a309f25f878b4c58a4eba890cb01 Mon Sep 17 00:00:00 2001 From: Ivan Chen Date: Wed, 23 Jun 2021 15:36:07 -0400 Subject: Cleanup code, Add support for video --- src/screens/profile/CaptionScreen.tsx | 43 +++++++++++++++++++++++------------ 1 file changed, 29 insertions(+), 14 deletions(-) (limited to 'src/screens/profile/CaptionScreen.tsx') diff --git a/src/screens/profile/CaptionScreen.tsx b/src/screens/profile/CaptionScreen.tsx index bb02494d..48724620 100644 --- a/src/screens/profile/CaptionScreen.tsx +++ b/src/screens/profile/CaptionScreen.tsx @@ -51,7 +51,7 @@ interface CaptionScreenProps { } const CaptionScreen: React.FC = ({route, navigation}) => { - const {title, media, screenType, selectedTags, moment} = route.params; + const {title, screenType, selectedTags, moment} = route.params; const { user: {userId}, } = useSelector((state: RootState) => state.user); @@ -62,6 +62,17 @@ const CaptionScreen: React.FC = ({route, navigation}) => { selectedTags ? selectedTags : [], ); const [taggedList, setTaggedList] = useState(''); + const mediaFilename = moment ? undefined : route.params.media!.filename; + const mediaUri = moment ? moment.moment_url : route.params.media!.uri; + // TODO: change this once moment refactor is done + const isMediaAVideo = moment + ? !( + moment.moment_url.endsWith('.jpg') || + moment.moment_url.endsWith('.JPG') || + moment.moment_url.endsWith('.png') || + moment.moment_url.endsWith('.PNG') + ) + : route.params.media?.type === 'video'; useEffect(() => { setTags(selectedTags ? selectedTags : []); @@ -120,12 +131,12 @@ const CaptionScreen: React.FC = ({route, navigation}) => { const handleShare = async () => { setLoading(true); - if (!media || !title) { + if (moment || !mediaFilename || !title) { return; } const momentResponse = await postMoment( - media.filename, - media.uri, + mediaFilename, + mediaUri, caption, title, userId, @@ -191,14 +202,18 @@ const CaptionScreen: React.FC = ({route, navigation}) => { - {/* this is the image we want to center our tags' initial location within */} - + {isMediaAVideo ? ( + //