diff options
Diffstat (limited to 'src/screens')
6 files changed, 135 insertions, 144 deletions
diff --git a/src/screens/main/NotificationsScreen.tsx b/src/screens/main/NotificationsScreen.tsx index bce48ef2..ebcccc8e 100644 --- a/src/screens/main/NotificationsScreen.tsx +++ b/src/screens/main/NotificationsScreen.tsx @@ -36,9 +36,8 @@ const NotificationsScreen: React.FC = () => { ); const [refreshing, setRefreshing] = useState(false); // used for figuring out which ones are unread - const [lastViewed, setLastViewed] = useState<moment.Moment | undefined>( - undefined, - ); + const [lastViewed, setLastViewed] = + useState<moment.Moment | undefined>(undefined); const {notifications} = useSelector( (state: RootState) => state.notifications, ); diff --git a/src/screens/profile/MomentCommentsScreen.tsx b/src/screens/profile/MomentCommentsScreen.tsx index 4b332b56..402e5f44 100644 --- a/src/screens/profile/MomentCommentsScreen.tsx +++ b/src/screens/profile/MomentCommentsScreen.tsx @@ -44,14 +44,12 @@ const MomentCommentsScreen: React.FC<MomentCommentsScreenProps> = ({route}) => { //Receives comment length from child CommentsContainer const [commentsLength, setCommentsLength] = useState<number>(0); - const [shouldUpdateAllComments, setShouldUpdateAllComments] = React.useState( - true, - ); + const [shouldUpdateAllComments, setShouldUpdateAllComments] = + React.useState(true); //Keeps track of the current comments object in focus so that the application knows which comment to post a reply to - const [commentTapped, setCommentTapped] = useState< - CommentType | CommentThreadType | undefined - >(); + const [commentTapped, setCommentTapped] = + useState<CommentType | CommentThreadType | undefined>(); useEffect(() => { navigation.setOptions({ diff --git a/src/screens/profile/MomentUploadPromptScreen.tsx b/src/screens/profile/MomentUploadPromptScreen.tsx index f0aaffc4..7e04063c 100644 --- a/src/screens/profile/MomentUploadPromptScreen.tsx +++ b/src/screens/profile/MomentUploadPromptScreen.tsx @@ -28,12 +28,8 @@ const MomentUploadPromptScreen: React.FC<MomentUploadPromptScreenProps> = ({ route, navigation, }) => { - const { - screenType, - momentCategory, - profileBodyHeight, - socialsBarHeight, - } = route.params; + const {screenType, momentCategory, profileBodyHeight, socialsBarHeight} = + route.params; return ( <View style={styles.container}> <CloseIcon diff --git a/src/screens/profile/SocialMediaTaggs.tsx b/src/screens/profile/SocialMediaTaggs.tsx index 52d20683..0e2ebb63 100644 --- a/src/screens/profile/SocialMediaTaggs.tsx +++ b/src/screens/profile/SocialMediaTaggs.tsx @@ -85,9 +85,9 @@ const SocialMediaTaggs: React.FC<SocialMediaTaggsProps> = ({ type={socialMediaType} handle={accountData?.handle} /> - {(accountData?.posts as Array< - SimplePostType | TwitterPostType - >).map((post, index) => + {( + accountData?.posts as Array<SimplePostType | TwitterPostType> + ).map((post, index) => socialMediaType === 'Twitter' ? ( <TwitterTaggPost key={index} diff --git a/src/screens/suggestedPeople/MutualBadgeHolders.tsx b/src/screens/suggestedPeople/MutualBadgeHolders.tsx index e3b69f7a..f715bd5e 100644 --- a/src/screens/suggestedPeople/MutualBadgeHolders.tsx +++ b/src/screens/suggestedPeople/MutualBadgeHolders.tsx @@ -37,9 +37,8 @@ const MutualBadgeHolders: React.FC<MutualBadgeHoldersProps> = ({ useEffect(() => { const getUsers = async () => { - let localUsers: - | ProfilePreviewType[] - | undefined = await getMutualBadgeHolders(badge_id); + let localUsers: ProfilePreviewType[] | undefined = + await getMutualBadgeHolders(badge_id); setUsers(localUsers); }; diff --git a/src/screens/suggestedPeopleOnboarding/SuggestedPeopleUploadPictureScreen.tsx b/src/screens/suggestedPeopleOnboarding/SuggestedPeopleUploadPictureScreen.tsx index af5fd579..f5a9f280 100644 --- a/src/screens/suggestedPeopleOnboarding/SuggestedPeopleUploadPictureScreen.tsx +++ b/src/screens/suggestedPeopleOnboarding/SuggestedPeopleUploadPictureScreen.tsx @@ -38,139 +38,138 @@ type SuggestedPeopleUploadPictureScreenProps = { route: SuggestedPeopleUploadPictureScreenRouteProp; }; -const SuggestedPeopleUploadPictureScreen: React.FC<SuggestedPeopleUploadPictureScreenProps> = ({ - route, -}) => { - const {editing} = route.params; - const [image, setImage] = useState<string | undefined>(undefined); - const [oldImage, setOldImage] = useState<string | undefined>(undefined); - const [loading, setLoading] = useState(false); - const dispatch = useDispatch(); - const navigation = useNavigation(); - const { - user: {userId: loggedInUserId}, - } = useSelector((state: RootState) => state.user); +const SuggestedPeopleUploadPictureScreen: React.FC<SuggestedPeopleUploadPictureScreenProps> = + ({route}) => { + const {editing} = route.params; + const [image, setImage] = useState<string | undefined>(undefined); + const [oldImage, setOldImage] = useState<string | undefined>(undefined); + const [loading, setLoading] = useState(false); + const dispatch = useDispatch(); + const navigation = useNavigation(); + const { + user: {userId: loggedInUserId}, + } = useSelector((state: RootState) => state.user); - useEffect(() => { - const loadData = async () => { - const response = await getSuggestedPeopleProfile(loggedInUserId); - if (response) { - setImage(response.suggested_people_url); - setOldImage(response.suggested_people_url); + useEffect(() => { + const loadData = async () => { + const response = await getSuggestedPeopleProfile(loggedInUserId); + if (response) { + setImage(response.suggested_people_url); + setOldImage(response.suggested_people_url); + } + }; + // if we're in edit SP, attempt to load current sp image + if (editing) { + loadData(); } - }; - // if we're in edit SP, attempt to load current sp image - if (editing) { - loadData(); - } - }, []); + }, []); - const openImagePicker = () => { - ImagePicker.openPicker({ - smartAlbums: [ - 'Favorites', - 'RecentlyAdded', - 'SelfPortraits', - 'Screenshots', - 'UserLibrary', - ], - width: SP_WIDTH, - height: SP_HEIGHT, - cropping: true, - cropperToolbarTitle: 'Select Photo', - mediaType: 'photo', - }) - .then((picture) => { - if ('path' in picture) { - setImage(picture.path); - } + const openImagePicker = () => { + ImagePicker.openPicker({ + smartAlbums: [ + 'Favorites', + 'RecentlyAdded', + 'SelfPortraits', + 'Screenshots', + 'UserLibrary', + ], + width: SP_WIDTH, + height: SP_HEIGHT, + cropping: true, + cropperToolbarTitle: 'Select Photo', + mediaType: 'photo', }) - .catch((_) => {}); - }; + .then((picture) => { + if ('path' in picture) { + setImage(picture.path); + } + }) + .catch((_) => {}); + }; - const uploadImage = async () => { - // Uploading image only if initially loaded image is not the same as the image being uploaded - if (image && oldImage !== image) { - setLoading(true); - const success = await sendSuggestedPeoplePhoto(image); - if (success) { - dispatch(uploadedSuggestedPeoplePhoto(image)); - if (!editing) { - navigation.navigate('BadgeSelection', {editing: false}); + const uploadImage = async () => { + // Uploading image only if initially loaded image is not the same as the image being uploaded + if (image && oldImage !== image) { + setLoading(true); + const success = await sendSuggestedPeoplePhoto(image); + if (success) { + dispatch(uploadedSuggestedPeoplePhoto(image)); + if (!editing) { + navigation.navigate('BadgeSelection', {editing: false}); + } + } else { + Alert.alert(ERROR_UPLOAD); + } + setLoading(false); + // Navigated back to Profile if user is editing their Suggested People Picture + if (editing) { + navigation.goBack(); + setTimeout(() => { + Alert.alert(success ? SUCCESS_PIC_UPLOAD : ERROR_UPLOAD_SP_PHOTO); + }, 500); } - } else { - Alert.alert(ERROR_UPLOAD); - } - setLoading(false); - // Navigated back to Profile if user is editing their Suggested People Picture - if (editing) { - navigation.goBack(); - setTimeout(() => { - Alert.alert(success ? SUCCESS_PIC_UPLOAD : ERROR_UPLOAD_SP_PHOTO); - }, 500); } - } - }; + }; - return ( - <> - {loading && <TaggLoadingIndicator fullscreen />} - <StatusBar barStyle={'light-content'} /> - <SafeAreaView style={styles.container}> - <Text style={editing ? styles.titleEditSuggested : styles.titlePHOTO}> - {editing ? 'Edit Suggested' : 'PHOTO'} - </Text> - {image ? ( - <Text style={styles.body}> - {editing - ? 'Tap to upload new photo' - : 'Tap again to choose another photo'} + return ( + <> + {loading && <TaggLoadingIndicator fullscreen />} + <StatusBar barStyle={'light-content'} /> + <SafeAreaView style={styles.container}> + <Text style={editing ? styles.titleEditSuggested : styles.titlePHOTO}> + {editing ? 'Edit Suggested' : 'PHOTO'} </Text> - ) : ( - <Text style={styles.body}> - Upload a photo, this is what other users will see - </Text> - )} - {image ? ( - <TouchableOpacity onPress={openImagePicker}> - <ImageBackground - source={{uri: image, cache: 'reload'}} - style={[styles.imageContainer, styles.overlay]} - borderRadius={30}> - <Image - style={styles.overlay} + {image ? ( + <Text style={styles.body}> + {editing + ? 'Tap to upload new photo' + : 'Tap again to choose another photo'} + </Text> + ) : ( + <Text style={styles.body}> + Upload a photo, this is what other users will see + </Text> + )} + {image ? ( + <TouchableOpacity onPress={openImagePicker}> + <ImageBackground + source={{uri: image, cache: 'reload'}} + style={[styles.imageContainer, styles.overlay]} + borderRadius={30}> + <Image + style={styles.overlay} + source={require('../../assets/images/suggested-people-preview-silhouette.png')} + /> + </ImageBackground> + </TouchableOpacity> + ) : ( + <TouchableOpacity onPress={openImagePicker}> + <ImageBackground source={require('../../assets/images/suggested-people-preview-silhouette.png')} - /> - </ImageBackground> - </TouchableOpacity> - ) : ( - <TouchableOpacity onPress={openImagePicker}> - <ImageBackground - source={require('../../assets/images/suggested-people-preview-silhouette.png')} - style={[styles.imageContainer, styles.overlay]}> - <Image - style={styles.images} - source={require('../../assets/images/images.png')} - /> - <Text style={styles.body}>Upload Photo</Text> - </ImageBackground> - </TouchableOpacity> - )} - {image && ( - <TaggSquareButton - onPress={uploadImage} - title={'Done'} - buttonStyle={'normal'} - buttonColor={editing ? 'blue' : 'purple'} - labelColor={'white'} - style={styles.buttonStyle} - labelStyle={styles.buttonLabel} - /> - )} - </SafeAreaView> - </> - ); -}; + style={[styles.imageContainer, styles.overlay]}> + <Image + style={styles.images} + source={require('../../assets/images/images.png')} + /> + <Text style={styles.body}>Upload Photo</Text> + </ImageBackground> + </TouchableOpacity> + )} + {image && ( + <TaggSquareButton + onPress={uploadImage} + title={'Done'} + buttonStyle={'normal'} + buttonColor={editing ? 'blue' : 'purple'} + labelColor={'white'} + style={styles.buttonStyle} + labelStyle={styles.buttonLabel} + /> + )} + </SafeAreaView> + </> + ); + }; const styles = StyleSheet.create({ container: { |