diff options
author | Ivan Chen <ivan@tagg.id> | 2021-07-07 14:38:10 -0400 |
---|---|---|
committer | Ivan Chen <ivan@tagg.id> | 2021-07-09 15:55:18 -0400 |
commit | 2697a10f65f84eb44757bc3b37c09bdc1989de5d (patch) | |
tree | c2fcf508974c203d56080ccf7b43d4e4aeab5a83 /src/screens/profile/CaptionScreen.tsx | |
parent | dda5964a5f334655826f36023025f90cb86364c8 (diff) |
Remove title, Cleanup caption screen route props, Add new screen
Diffstat (limited to 'src/screens/profile/CaptionScreen.tsx')
-rw-r--r-- | src/screens/profile/CaptionScreen.tsx | 39 |
1 files changed, 20 insertions, 19 deletions
diff --git a/src/screens/profile/CaptionScreen.tsx b/src/screens/profile/CaptionScreen.tsx index 67d1fd04..025d81a7 100644 --- a/src/screens/profile/CaptionScreen.tsx +++ b/src/screens/profile/CaptionScreen.tsx @@ -14,7 +14,6 @@ import { TouchableWithoutFeedback, View, } from 'react-native'; -import {openContactForm} from 'react-native-contacts'; import {Button} from 'react-native-elements'; import Video from 'react-native-video'; import {useDispatch, useSelector} from 'react-redux'; @@ -48,27 +47,28 @@ import {mentionPartTypes} from '../../utils/comments'; * Upload Screen to allow users to upload posts to Tagg */ type CaptionScreenRouteProp = RouteProp<MainStackParams, 'CaptionScreen'>; + type CaptionScreenNavigationProp = StackNavigationProp< MainStackParams, 'CaptionScreen' >; + interface CaptionScreenProps { route: CaptionScreenRouteProp; navigation: CaptionScreenNavigationProp; } const CaptionScreen: React.FC<CaptionScreenProps> = ({route, navigation}) => { - const {title, screenType, selectedTags, moment} = route.params; + const {screenType, moment} = route.params; const { user: {userId}, } = useSelector((state: RootState) => state.user); const dispatch = useDispatch(); const [caption, setCaption] = useState(moment ? moment.caption : ''); const [loading, setLoading] = useState(false); - const [tags, setTags] = useState<MomentTagType[]>( - selectedTags ? selectedTags : [], - ); + const [tags, setTags] = useState<MomentTagType[]>([]); const [taggedUsersText, setTaggedUsersText] = useState(''); + const [momentCategory, setMomentCategory] = useState<string | undefined>(); const mediaUri = moment ? moment.moment_url : route.params.media!.uri; // TODO: change this once moment refactor is done const isMediaAVideo = moment @@ -81,8 +81,12 @@ const CaptionScreen: React.FC<CaptionScreenProps> = ({route, navigation}) => { : route.params.media?.isVideo ?? false; useEffect(() => { - setTags(selectedTags ? selectedTags : []); - }, [selectedTags]); + setTags(route.params.selectedTags ?? []); + }, [route.params.selectedTags]); + + useEffect(() => { + setMomentCategory(route.params.selectedCategory); + }, [route.params.selectedCategory]); useEffect(() => { let listString = ''; @@ -145,7 +149,7 @@ const CaptionScreen: React.FC<CaptionScreenProps> = ({route, navigation}) => { const handleShare = async () => { setLoading(true); - if (moment || !title) { + if (moment || !momentCategory) { handleFailed(); return; } @@ -153,7 +157,7 @@ const CaptionScreen: React.FC<CaptionScreenProps> = ({route, navigation}) => { let momentId; // separate upload logic for image/video if (isMediaAVideo) { - const presignedURLResponse = await handlePresignedURL(title); + const presignedURLResponse = await handlePresignedURL(momentCategory); if (!presignedURLResponse) { handleFailed(); return; @@ -166,7 +170,12 @@ const CaptionScreen: React.FC<CaptionScreenProps> = ({route, navigation}) => { handleFailed(); } } else { - const momentResponse = await postMoment(mediaUri, caption, title, userId); + const momentResponse = await postMoment( + mediaUri, + caption, + momentCategory, + userId, + ); if (!momentResponse) { handleFailed(); return; @@ -276,15 +285,7 @@ const CaptionScreen: React.FC<CaptionScreenProps> = ({route, navigation}) => { <SelectableItem text={'Category'} imageUri={require('../../assets/images/images.png')} - onPress={() => - navigation.navigate('TagFriendsScreen', { - media: { - uri: mediaUri, - isVideo: isMediaAVideo, - }, - selectedTags: tags, - }) - } + onPress={() => navigation.navigate('ChoosingCategoryScreen', {})} /> <SelectableItem text={'Tag Friends'} |