From 5ff7cab4bd36337b2c86e3d4915a6fc3ceef1ddb Mon Sep 17 00:00:00 2001 From: Ivan Chen Date: Tue, 20 Apr 2021 17:10:33 -0400 Subject: linted --- src/components/comments/CommentTile.tsx | 6 +++--- src/components/profile/Friends.tsx | 4 +--- 2 files changed, 4 insertions(+), 6 deletions(-) (limited to 'src/components') diff --git a/src/components/comments/CommentTile.tsx b/src/components/comments/CommentTile.tsx index be113523..34eef418 100644 --- a/src/components/comments/CommentTile.tsx +++ b/src/components/comments/CommentTile.tsx @@ -108,7 +108,7 @@ const CommentTile: React.FC = ({ ? `Replies (${comment_object.replies_count})` : 'Replies'; - const renderRightAction = (text: string, color: string, progress) => { + const renderRightAction = (text: string, color: string) => { const pressHandler = async () => { swipeRef.current?.close(); const success = await deleteComment(comment_object.comment_id, isThread); @@ -130,10 +130,10 @@ const CommentTile: React.FC = ({ ); }; - const renderRightActions = (progress: Animated.AnimatedInterpolation) => + const renderRightActions = (_: Animated.AnimatedInterpolation) => canDelete ? ( - {renderRightAction('Delete', '#c42634', progress)} + {renderRightAction('Delete', '#c42634')} ) : ( diff --git a/src/components/profile/Friends.tsx b/src/components/profile/Friends.tsx index b754b71a..a7a06567 100644 --- a/src/components/profile/Friends.tsx +++ b/src/components/profile/Friends.tsx @@ -1,4 +1,3 @@ -import {useNavigation} from '@react-navigation/native'; import React, {useEffect, useState} from 'react'; import {ScrollView, StyleSheet, Text, View} from 'react-native'; import {checkPermission} from 'react-native-contacts'; @@ -21,14 +20,13 @@ import {ProfilePreview} from '../profile'; interface FriendsProps { result: Array; screenType: ScreenType; - userId: string; + userId: string | undefined; } const Friends: React.FC = ({result, screenType, userId}) => { const state: RootState = useStore().getState(); const dispatch = useDispatch(); const {user: loggedInUser = NO_USER} = state.user; - const navigation = useNavigation(); const [usersFromContacts, setUsersFromContacts] = useState< ProfilePreviewType[] >([]); -- cgit v1.2.3-70-g09d2 From bae0136cb1939302b758249a1978251bd37aaee8 Mon Sep 17 00:00:00 2001 From: Ivan Chen Date: Tue, 20 Apr 2021 17:16:46 -0400 Subject: linted --- src/components/common/AcceptDeclineButtons.tsx | 8 ++------ src/components/common/FriendsButton.tsx | 9 ++++++--- src/components/common/TaggPrompt.tsx | 14 ++++++-------- src/components/messages/TypingIndicator.tsx | 3 ++- src/components/moments/MomentPostHeader.tsx | 2 +- src/components/notifications/Notification.tsx | 1 - src/components/profile/ProfileMoreInfoDrawer.tsx | 6 ++---- src/components/profile/ProfilePreview.tsx | 1 - src/components/search/SearchResultList.tsx | 3 ++- src/components/suggestedPeople/SPTaggsBar.tsx | 2 -- src/routes/Routes.tsx | 3 +-- src/screens/badge/BadgeItem.tsx | 8 +++++--- 12 files changed, 27 insertions(+), 33 deletions(-) (limited to 'src/components') diff --git a/src/components/common/AcceptDeclineButtons.tsx b/src/components/common/AcceptDeclineButtons.tsx index 7bb62fd4..fd42f2f5 100644 --- a/src/components/common/AcceptDeclineButtons.tsx +++ b/src/components/common/AcceptDeclineButtons.tsx @@ -1,19 +1,15 @@ import React from 'react'; import {StyleProp, StyleSheet, Text, View, ViewStyle} from 'react-native'; -import {TAGG_LIGHT_BLUE} from '../../constants'; -import {ProfilePreviewType} from '../../types'; -import {SCREEN_WIDTH} from '../../utils'; import {TouchableOpacity} from 'react-native-gesture-handler'; -import {normalize} from '../../utils'; +import {TAGG_LIGHT_BLUE} from '../../constants'; +import {normalize, SCREEN_WIDTH} from '../../utils'; interface AcceptDeclineButtonsProps { - requester: ProfilePreviewType; onAccept: () => void; onReject: () => void; externalStyles?: Record>; } const AcceptDeclineButtons: React.FC = ({ - requester, onAccept, onReject, externalStyles, diff --git a/src/components/common/FriendsButton.tsx b/src/components/common/FriendsButton.tsx index 6ddad93f..ae901229 100644 --- a/src/components/common/FriendsButton.tsx +++ b/src/components/common/FriendsButton.tsx @@ -31,9 +31,12 @@ const FriendsButton: React.FC = ({ }) => { const dispatch = useDispatch(); - const {user = NO_USER, profile = NO_PROFILE} = userXId - ? useSelector((state: RootState) => state.userX[screenType][userXId]) - : useSelector((state: RootState) => state.user); + const { + user = NO_USER, + profile = NO_PROFILE, + } = useSelector((state: RootState) => + userXId ? state.userX[screenType][userXId] : state.user, + ); const {user: loggedInUser = NO_USER} = useSelector( (state: RootState) => state.user, diff --git a/src/components/common/TaggPrompt.tsx b/src/components/common/TaggPrompt.tsx index 5e125d00..6b59d4a5 100644 --- a/src/components/common/TaggPrompt.tsx +++ b/src/components/common/TaggPrompt.tsx @@ -1,8 +1,8 @@ -import * as React from 'react'; +import React from 'react'; import {StyleSheet, Text, TouchableOpacity} from 'react-native'; import {Image, View} from 'react-native-animatable'; import CloseIcon from '../../assets/ionicons/close-outline.svg'; -import {isIPhoneX, normalize, SCREEN_HEIGHT} from '../../utils'; +import {normalize, SCREEN_HEIGHT} from '../../utils'; type TaggPromptProps = { messageHeader: string; @@ -39,13 +39,11 @@ const TaggPrompt: React.FC = ({ } }; + const topPadding = {paddingTop: noPadding ? 0 : SCREEN_HEIGHT / 10}; + const bottomPadding = {paddingBottom: noPadding ? 0 : SCREEN_HEIGHT / 50}; + return ( - + {messageHeader} {messageBody} diff --git a/src/components/messages/TypingIndicator.tsx b/src/components/messages/TypingIndicator.tsx index be7141a2..b7c33567 100644 --- a/src/components/messages/TypingIndicator.tsx +++ b/src/components/messages/TypingIndicator.tsx @@ -7,7 +7,7 @@ const TypingIndicator: React.FC = () => { ); @@ -25,6 +25,7 @@ const styles = StyleSheet.create({ justifyContent: 'center', alignItems: 'center', }, + image: {width: 88, height: 49}, }); export default TypingIndicator; diff --git a/src/components/moments/MomentPostHeader.tsx b/src/components/moments/MomentPostHeader.tsx index ff324c4a..8cf509ab 100644 --- a/src/components/moments/MomentPostHeader.tsx +++ b/src/components/moments/MomentPostHeader.tsx @@ -31,11 +31,11 @@ const MomentPostHeader: React.FC = ({ }) => { const [drawerVisible, setDrawerVisible] = useState(false); const dispatch = useDispatch(); - const state: RootState = useStore().getState(); const navigation = useNavigation(); const {userId: loggedInUserId, username: loggedInUserName} = useSelector( (state: RootState) => state.user.user, ); + const state: RootState = useStore().getState(); const isOwnProfile = loggedInUserName === username; const navigateToProfile = async () => { if (userXId && !userXInStore(state, screenType, userXId)) { diff --git a/src/components/notifications/Notification.tsx b/src/components/notifications/Notification.tsx index 8e008cf9..87309c53 100644 --- a/src/components/notifications/Notification.tsx +++ b/src/components/notifications/Notification.tsx @@ -244,7 +244,6 @@ const Notification: React.FC = (props) => { {notification_type === 'FRD_REQ' && ( diff --git a/src/components/profile/ProfileMoreInfoDrawer.tsx b/src/components/profile/ProfileMoreInfoDrawer.tsx index 67e59747..ecc45211 100644 --- a/src/components/profile/ProfileMoreInfoDrawer.tsx +++ b/src/components/profile/ProfileMoreInfoDrawer.tsx @@ -1,10 +1,9 @@ import {useNavigation} from '@react-navigation/native'; import React from 'react'; -import {Alert, Image, StyleSheet, TouchableOpacity} from 'react-native'; +import {Image, StyleSheet, TouchableOpacity} from 'react-native'; import {useSelector} from 'react-redux'; import MoreIcon from '../../assets/icons/more_horiz-24px.svg'; import {TAGG_DARK_BLUE, TAGG_LIGHT_BLUE} from '../../constants'; -import {ERROR_ATTEMPT_EDIT_SP} from '../../constants/strings'; import {RootState} from '../../store/rootreducer'; import {SCREEN_HEIGHT, SCREEN_WIDTH} from '../../utils'; import {GenericMoreInfoDrawer} from '../common'; @@ -23,8 +22,7 @@ const ProfileMoreInfoDrawer: React.FC = (props) => { const {setIsOpen, userXId, isBlocked, handleBlockUnblock, userXName} = props; const { user: {userId, username}, - profile, - } = useSelector((state: RootState) => state?.user); + } = useSelector((state: RootState) => state.user); const isOwnProfile = !userXId || userXName === username; const goToEditProfile = () => { diff --git a/src/components/profile/ProfilePreview.tsx b/src/components/profile/ProfilePreview.tsx index 9afb4aba..bea989d9 100644 --- a/src/components/profile/ProfilePreview.tsx +++ b/src/components/profile/ProfilePreview.tsx @@ -1,4 +1,3 @@ -import AsyncStorage from '@react-native-community/async-storage'; import {useNavigation} from '@react-navigation/native'; import React, {useEffect, useState} from 'react'; import { diff --git a/src/components/search/SearchResultList.tsx b/src/components/search/SearchResultList.tsx index a32760e1..dab447fb 100644 --- a/src/components/search/SearchResultList.tsx +++ b/src/components/search/SearchResultList.tsx @@ -32,6 +32,7 @@ const sectionHeader: React.FC = (showBorder: Boolean) => { const SearchResultList: React.FC = ({results}) => { const [showEmptyView, setshowEmptyView] = useState(false); const {user: loggedInUser} = useSelector((state: RootState) => state.user); + const tabBarHeight = useBottomTabBarHeight(); useEffect(() => { if (results && results.length > 0) { @@ -50,7 +51,7 @@ const SearchResultList: React.FC = ({results}) => { ) : ( item.id + index} renderItem={({item}) => { diff --git a/src/components/suggestedPeople/SPTaggsBar.tsx b/src/components/suggestedPeople/SPTaggsBar.tsx index 29c58cce..6fe8cef4 100644 --- a/src/components/suggestedPeople/SPTaggsBar.tsx +++ b/src/components/suggestedPeople/SPTaggsBar.tsx @@ -26,8 +26,6 @@ const TaggsBar: React.FC = ({ const {user} = useSelector((state: RootState) => userXId ? state.userX[screenType][userXId] : state.user, ); - const state: RootState = useStore().getState(); - const allowTaggsNavigation = canViewProfile(state, userXId, screenType); const dispatch = useDispatch(); diff --git a/src/routes/Routes.tsx b/src/routes/Routes.tsx index 04c081da..6fc766ab 100644 --- a/src/routes/Routes.tsx +++ b/src/routes/Routes.tsx @@ -1,4 +1,3 @@ -import AsyncStorage from '@react-native-community/async-storage'; import messaging from '@react-native-firebase/messaging'; import React, {useContext, useEffect, useState} from 'react'; import DeviceInfo from 'react-native-device-info'; @@ -11,7 +10,7 @@ import { updateNewVersionAvailable, } from '../store/actions'; import {RootState} from '../store/rootReducer'; -import {userLogin, connectChatAccount} from '../utils'; +import {connectChatAccount, userLogin} from '../utils'; import Onboarding from './onboarding'; import NavigationBar from './tabs'; diff --git a/src/screens/badge/BadgeItem.tsx b/src/screens/badge/BadgeItem.tsx index 3141e662..1994ce2a 100644 --- a/src/screens/badge/BadgeItem.tsx +++ b/src/screens/badge/BadgeItem.tsx @@ -32,9 +32,7 @@ const BadgeItem: React.FC = ({ useAngle={true} angle={136.69} style={styles.border}> - onSelection(title)} - style={{alignSelf: 'center', marginTop: 3}}> + onSelection(title)} style={button}> Date: Tue, 20 Apr 2021 17:49:38 -0400 Subject: linted --- src/components/common/AvatarTitle.tsx | 2 +- src/components/common/TaggLoadingIndicator.tsx | 2 +- src/components/suggestedPeople/SPTaggsBar.tsx | 3 +- src/screens/badge/BadgeItem.tsx | 12 +--- src/screens/badge/BadgeSelection.tsx | 12 ++-- src/screens/chat/ChatSearchBar.tsx | 3 +- src/screens/main/NotificationsScreen.tsx | 9 +-- src/screens/onboarding/OnboardingStepThree.tsx | 4 +- src/screens/onboarding/ProfileOnboarding.tsx | 2 +- src/screens/onboarding/RegistrationThree.tsx | 26 ++++----- src/screens/onboarding/SocialMedia.tsx | 3 +- src/screens/profile/EditProfile.tsx | 78 ++++++++++++-------------- src/screens/profile/SocialMediaTaggs.tsx | 38 +++++-------- 13 files changed, 84 insertions(+), 110 deletions(-) (limited to 'src/components') diff --git a/src/components/common/AvatarTitle.tsx b/src/components/common/AvatarTitle.tsx index a38f46fa..81351327 100644 --- a/src/components/common/AvatarTitle.tsx +++ b/src/components/common/AvatarTitle.tsx @@ -8,7 +8,7 @@ type AvatarTitleProps = { }; const AvatarTitle: React.FC = ({avatar}) => { return ( - + = ({ diff --git a/src/components/suggestedPeople/SPTaggsBar.tsx b/src/components/suggestedPeople/SPTaggsBar.tsx index 6fe8cef4..3ab33da1 100644 --- a/src/components/suggestedPeople/SPTaggsBar.tsx +++ b/src/components/suggestedPeople/SPTaggsBar.tsx @@ -1,13 +1,12 @@ import React, {useEffect, useState} from 'react'; import {StyleSheet} from 'react-native'; import Animated from 'react-native-reanimated'; -import {useDispatch, useSelector, useStore} from 'react-redux'; +import {useDispatch, useSelector} from 'react-redux'; import {INTEGRATED_SOCIAL_LIST, SOCIAL_LIST} from '../../constants'; import {getLinkedSocials} from '../../services'; import {loadIndividualSocial, updateSocial} from '../../store/actions'; import {RootState} from '../../store/rootReducer'; import {ScreenType} from '../../types'; -import {canViewProfile} from '../../utils'; import Tagg from '../taggs/Tagg'; const {View, ScrollView} = Animated; diff --git a/src/screens/badge/BadgeItem.tsx b/src/screens/badge/BadgeItem.tsx index 1994ce2a..1051d4a7 100644 --- a/src/screens/badge/BadgeItem.tsx +++ b/src/screens/badge/BadgeItem.tsx @@ -32,7 +32,9 @@ const BadgeItem: React.FC = ({ useAngle={true} angle={136.69} style={styles.border}> - onSelection(title)} style={button}> + onSelection(title)} + style={styles.button}> = ({ onChangeText, value, onCancel, - searching, animationProgress, onLayout, placeholder, @@ -53,7 +52,7 @@ const ChatSearchBar: React.FC = ({ To: = ({ route, navigation, }) => { - const {userId, username} = route.params; + const {userId} = route.params; const [form, setForm] = React.useState({ smallPic: '', university: UniversityType.Empty, @@ -135,7 +135,7 @@ const OnboardingStepThree: React.FC = ({ }; const handleClassYearUpdate = (value: string) => { - const classYear = Number.parseInt(value); + const classYear = parseInt(value, 10); setForm({ ...form, classYear, diff --git a/src/screens/onboarding/ProfileOnboarding.tsx b/src/screens/onboarding/ProfileOnboarding.tsx index c173c8e3..03ca858e 100644 --- a/src/screens/onboarding/ProfileOnboarding.tsx +++ b/src/screens/onboarding/ProfileOnboarding.tsx @@ -242,7 +242,7 @@ const ProfileOnboarding: React.FC = ({ }; const handleClassYearUpdate = (value: string) => { - const classYear = Number.parseInt(value); + const classYear = parseInt(value, 10); setForm({ ...form, classYear, diff --git a/src/screens/onboarding/RegistrationThree.tsx b/src/screens/onboarding/RegistrationThree.tsx index 03348e6b..1f4266ff 100644 --- a/src/screens/onboarding/RegistrationThree.tsx +++ b/src/screens/onboarding/RegistrationThree.tsx @@ -3,38 +3,36 @@ * Purpose : Add a new screen to allow the user to enter first and last name */ -import React, {useState, useRef} from 'react'; +import AsyncStorage from '@react-native-community/async-storage'; import {RouteProp} from '@react-navigation/native'; import {StackNavigationProp} from '@react-navigation/stack'; +import React, {useRef, useState} from 'react'; import { - View, - Text, - StyleSheet, - StatusBar, Alert, + KeyboardAvoidingView, Platform, + StatusBar, + StyleSheet, + Text, TouchableOpacity, - KeyboardAvoidingView, - ActivityIndicator, + View, } from 'react-native'; - -import {OnboardingStackParams} from '../../routes'; import { ArrowButton, + Background, + LoadingIndicator, RegistrationWizard, TaggInput, TermsConditions, - Background, - LoadingIndicator, } from '../../components'; -import {passwordRegex, usernameRegex, REGISTER_ENDPOINT} from '../../constants'; -import AsyncStorage from '@react-native-community/async-storage'; -import {BackgroundGradientType} from '../../types'; +import {passwordRegex, REGISTER_ENDPOINT, usernameRegex} from '../../constants'; import { ERROR_DOUBLE_CHECK_CONNECTION, ERROR_REGISTRATION, ERROR_SOMETHING_WENT_WRONG_REFRESH, } from '../../constants/strings'; +import {OnboardingStackParams} from '../../routes'; +import {BackgroundGradientType} from '../../types'; type RegistrationScreenThreeRouteProp = RouteProp< OnboardingStackParams, diff --git a/src/screens/onboarding/SocialMedia.tsx b/src/screens/onboarding/SocialMedia.tsx index 2a978f94..0ded7d3e 100644 --- a/src/screens/onboarding/SocialMedia.tsx +++ b/src/screens/onboarding/SocialMedia.tsx @@ -10,7 +10,6 @@ import { TouchableOpacity, View, } from 'react-native'; -import {useDispatch} from 'react-redux'; import { BackgroundGradientType, CategorySelectionScreenType, @@ -21,7 +20,7 @@ import { LinkSocialMedia, RegistrationWizard, } from '../../components'; -import {SOCIAL_LIST, MOMENT_CATEGORIES} from '../../constants/'; +import {SOCIAL_LIST} from '../../constants/'; import {OnboardingStackParams} from '../../routes'; /** diff --git a/src/screens/profile/EditProfile.tsx b/src/screens/profile/EditProfile.tsx index 8b658043..36abb146 100644 --- a/src/screens/profile/EditProfile.tsx +++ b/src/screens/profile/EditProfile.tsx @@ -199,12 +199,12 @@ const EditProfile: React.FC = ({route, navigation}) => { /* * Handles changes to the website field value and verifies the input by updating state and running a validation function. */ - const handleWebsiteUpdate = (website: string) => { - website = website.trim(); - let isValidWebsite: boolean = websiteRegex.test(website); + const handleWebsiteUpdate = (newWebsite: string) => { + newWebsite = newWebsite.trim(); + let isValidWebsite: boolean = websiteRegex.test(newWebsite); setForm({ ...form, - website, + website: newWebsite, isValidWebsite, }); }; @@ -212,27 +212,27 @@ const EditProfile: React.FC = ({route, navigation}) => { /* * Handles changes to the bio field value and verifies the input by updating state and running a validation function. */ - const handleBioUpdate = (bio: string) => { - let isValidBio: boolean = bioRegex.test(bio); + const handleBioUpdate = (newBio: string) => { + let isValidBio: boolean = bioRegex.test(newBio); setForm({ ...form, - bio, + bio: newBio, isValidBio, }); }; - const handleGenderUpdate = (gender: string) => { - if (gender === 'custom') { - setForm({...form, gender}); + const handleGenderUpdate = (newGender: string) => { + if (newGender === 'custom') { + setForm({...form, gender: newGender}); setIsCustomGender(true); - } else if (gender === null) { + } else if (newGender === null) { // not doing anything will make the picker "bounce back" } else { setIsCustomGender(false); let isValidGender: boolean = true; setForm({ ...form, - gender, + gender: newGender, isValidGender, }); } @@ -383,8 +383,8 @@ const EditProfile: React.FC = ({route, navigation}) => { headerRight: () => (