diff options
author | Ivan Chen <ivan@tagg.id> | 2021-04-22 14:32:15 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-22 14:32:15 -0400 |
commit | f0cff95cfa612b295caf68552bc3d29a7fb23a42 (patch) | |
tree | dd3df697478a19048cd4bf6d0b499a91c1a93eb3 /src | |
parent | 4e8e1c0d58424e6b63cfb8470fc0a73c0e6b102b (diff) | |
parent | 33c172cc31957966b14321520c56816ba044db14 (diff) |
Merge pull request #374 from IvanIFChen/hotfix-linting-fixup
[HOTFIX] Linter fixup
Diffstat (limited to 'src')
40 files changed, 183 insertions, 224 deletions
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<CommentTileProps> = ({ ? `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<CommentTileProps> = ({ ); }; - const renderRightActions = (progress: Animated.AnimatedInterpolation) => + const renderRightActions = (_: Animated.AnimatedInterpolation) => canDelete ? ( <View style={styles.swipeActions}> - {renderRightAction('Delete', '#c42634', progress)} + {renderRightAction('Delete', '#c42634')} </View> ) : ( <Fragment /> 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<string, StyleProp<ViewStyle>>; } const AcceptDeclineButtons: React.FC<AcceptDeclineButtonsProps> = ({ - requester, onAccept, onReject, externalStyles, 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<AvatarTitleProps> = ({avatar}) => { return ( - <View style={[styles.container]}> + <View style={styles.container}> <LinearGradient colors={[TAGGS_GRADIENT.start, TAGGS_GRADIENT.end]} useAngle={true} 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<FriendsButtonProps> = ({ }) => { 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/TaggLoadingIndicator.tsx b/src/components/common/TaggLoadingIndicator.tsx index 91c68622..a829cb6f 100644 --- a/src/components/common/TaggLoadingIndicator.tsx +++ b/src/components/common/TaggLoadingIndicator.tsx @@ -3,7 +3,7 @@ import {Image, StyleSheet, View} from 'react-native'; import {SCREEN_HEIGHT, SCREEN_WIDTH} from '../../utils'; interface TaggLoadingIndicatorProps { - fullscreen: boolean; + fullscreen?: boolean; } const TaggLoadingIndicator: React.FC<TaggLoadingIndicatorProps> = ({ 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<TaggPromptProps> = ({ } }; + const topPadding = {paddingTop: noPadding ? 0 : SCREEN_HEIGHT / 10}; + const bottomPadding = {paddingBottom: noPadding ? 0 : SCREEN_HEIGHT / 50}; + return ( - <View - style={[ - styles.container, - {paddingTop: noPadding ? 0 : SCREEN_HEIGHT / 10}, - {paddingBottom: noPadding ? 0 : SCREEN_HEIGHT / 50}, - ]}> + <View style={[styles.container, topPadding, bottomPadding]}> <Image style={styles.icon} source={logo()} /> <Text style={styles.header}>{messageHeader}</Text> <Text style={styles.subtext}>{messageBody}</Text> diff --git a/src/components/messages/ChatInput.tsx b/src/components/messages/ChatInput.tsx index 005d4401..bde5fc12 100644 --- a/src/components/messages/ChatInput.tsx +++ b/src/components/messages/ChatInput.tsx @@ -1,12 +1,10 @@ import React from 'react'; import {Image, StyleSheet, View} from 'react-native'; import {TouchableOpacity} from 'react-native-gesture-handler'; -import ImagePicker from 'react-native-image-crop-picker'; import {useStore} from 'react-redux'; import { AutoCompleteInput, MessageInputProps, - useAttachmentPickerContext, useMessageInputContext, } from 'stream-chat-react-native'; import {RootState} from '../../store/rootReducer'; @@ -35,35 +33,35 @@ const ChatInput: React.FC< > = () => { const state: RootState = useStore().getState(); const avatar = state.user.avatar; - const {sendMessage, text, setText, uploadNewImage} = useMessageInputContext(); - const { - setSelectedImages, - selectedImages, - openPicker, - } = useAttachmentPickerContext(); + const {sendMessage, text, setText} = useMessageInputContext(); + // const { + // setSelectedImages, + // selectedImages, + // openPicker, + // } = useAttachmentPickerContext(); - const selectImage = () => { - ImagePicker.openPicker({ - cropping: true, - freeStyleCropEnabled: true, - mediaType: 'photo', - multiple: true, - // includeBase64: true, - }) - .then((pictures) => { - pictures.map((pic) => - uploadNewImage({ - width: pic.width, - height: pic.height, - source: 'picker', - uri: 'ph://' + pic.localIdentifier, - }), - ); - }) - .catch((error) => { - console.log(error); - }); - }; + // const selectImage = () => { + // ImagePicker.openPicker({ + // cropping: true, + // freeStyleCropEnabled: true, + // mediaType: 'photo', + // multiple: true, + // // includeBase64: true, + // }) + // .then((pictures) => { + // pictures.map((pic) => + // uploadNewImage({ + // width: pic.width, + // height: pic.height, + // source: 'picker', + // uri: 'ph://' + pic.localIdentifier, + // }), + // ); + // }) + // .catch((error) => { + // console.log(error); + // }); + // }; return ( <View style={styles.container}> @@ -139,7 +137,6 @@ const styles = StyleSheet.create({ marginRight: 10, width: 100, alignSelf: 'flex-end', - // borderWidth: 1, }, }); 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 = () => { <View style={styles.typingIndicatorContainer}> <Image source={require('../../assets/gifs/loading-animation.gif')} - style={{width: 88, height: 49}} + style={styles.image} /> </View> ); @@ -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<MomentPostHeaderProps> = ({ }) => { 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/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<ProfilePreviewType>; screenType: ScreenType; - userId: string; + userId: string | undefined; } const Friends: React.FC<FriendsProps> = ({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[] >([]); 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<ProfileMoreInfoDrawerProps> = (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/profile/PublicProfile.tsx b/src/components/profile/PublicProfile.tsx index d2ee8626..b8920351 100644 --- a/src/components/profile/PublicProfile.tsx +++ b/src/components/profile/PublicProfile.tsx @@ -15,17 +15,9 @@ import { deleteUserMomentsForCategory, updateMomentCategories, } from '../../store/actions'; -import { - EMPTY_MOMENTS_LIST, - NO_PROFILE, - NO_USER, -} from '../../store/initialStates'; +import {EMPTY_MOMENTS_LIST, NO_PROFILE} from '../../store/initialStates'; import {RootState} from '../../store/rootreducer'; -import { - CategorySelectionScreenType, - ContentProps, - MomentType, -} from '../../types'; +import {ContentProps, MomentType} from '../../types'; import {moveCategory, normalize, SCREEN_HEIGHT} from '../../utils'; import {TaggPrompt} from '../common'; import {Moment} from '../moments'; @@ -52,10 +44,6 @@ const PublicProfile: React.FC<ContentProps> = ({ userXId ? state.userX[screenType][userXId] : state.momentCategories, ); - const {user: loggedInUser = NO_USER} = useSelector( - (state: RootState) => state.user, - ); - const navigation = useNavigation(); /** 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<Boolean> = (showBorder: Boolean) => { const SearchResultList: React.FC<SearchResultsProps> = ({results}) => { const [showEmptyView, setshowEmptyView] = useState<boolean>(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<SearchResultsProps> = ({results}) => { ) : ( <SectionList onScrollBeginDrag={Keyboard.dismiss} - contentContainerStyle={[{paddingBottom: useBottomTabBarHeight()}]} + contentContainerStyle={[{paddingBottom: tabBarHeight}]} sections={results} keyExtractor={(item, index) => item.id + index} renderItem={({item}) => { diff --git a/src/components/suggestedPeople/SPTaggsBar.tsx b/src/components/suggestedPeople/SPTaggsBar.tsx index 29c58cce..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; @@ -26,8 +25,6 @@ const TaggsBar: React.FC<TaggsBarProps> = ({ 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/components/taggs/TwitterTaggPost.tsx b/src/components/taggs/TwitterTaggPost.tsx index b2889e3e..0a6f53d8 100644 --- a/src/components/taggs/TwitterTaggPost.tsx +++ b/src/components/taggs/TwitterTaggPost.tsx @@ -1,12 +1,17 @@ import React from 'react'; -import { Image, Linking, StyleSheet, View } from 'react-native'; -import { Text } from 'react-native-animatable'; +import {Image, Linking, StyleSheet, View} from 'react-native'; +import {Text} from 'react-native-animatable'; import Hyperlink from 'react-native-hyperlink'; import LinearGradient from 'react-native-linear-gradient'; -import { AVATAR_DIM, TAGGS_GRADIENT, TAGG_LIGHT_BLUE, TAGG_LIGHT_BLUE_2 } from '../../constants'; -import { TwitterPostType } from '../../types'; -import { handleOpenSocialUrlOnBrowser, SCREEN_WIDTH } from '../../utils'; -import { DateLabel, PostCarousel } from '../common'; +import { + AVATAR_DIM, + TAGGS_GRADIENT, + TAGG_LIGHT_BLUE, + TAGG_LIGHT_BLUE_2, +} from '../../constants'; +import {TwitterPostType} from '../../types'; +import {handleOpenSocialUrlOnBrowser, SCREEN_WIDTH} from '../../utils'; +import {DateLabel, PostCarousel} from '../common'; interface TwitterTaggPostProps { ownerHandle: string; 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..1051d4a7 100644 --- a/src/screens/badge/BadgeItem.tsx +++ b/src/screens/badge/BadgeItem.tsx @@ -34,7 +34,7 @@ const BadgeItem: React.FC<BadgeItemProps> = ({ style={styles.border}> <TouchableOpacity onPress={() => onSelection(title)} - style={{alignSelf: 'center', marginTop: 3}}> + style={styles.button}> <LinearGradient colors={index === 0 ? BADGE_GRADIENT_FIRST : BADGE_GRADIENT_REST} // BACKGROUND_GRADIENT_MAP @@ -74,14 +74,6 @@ const styles = StyleSheet.create({ borderRadius: 8, borderColor: 'transparent', }, - selectedDetailContainer: { - flexGrow: 1, - justifyContent: 'center', - alignItems: 'center', - borderWidth: 3, - borderColor: 'white', - borderRadius: 8, - }, imageStyles: { width: 40, height: 40, @@ -96,6 +88,10 @@ const styles = StyleSheet.create({ color: 'white', marginHorizontal: '2%', }, + button: { + alignSelf: 'center', + marginTop: 3, + }, }); export default BadgeItem; diff --git a/src/screens/badge/BadgeSelection.tsx b/src/screens/badge/BadgeSelection.tsx index 2fec8ea3..91617377 100644 --- a/src/screens/badge/BadgeSelection.tsx +++ b/src/screens/badge/BadgeSelection.tsx @@ -1,26 +1,26 @@ import {RouteProp} from '@react-navigation/core'; +import {useNavigation} from '@react-navigation/native'; import React, {useEffect, useState} from 'react'; import {Alert, SafeAreaView, StatusBar, StyleSheet, View} from 'react-native'; import {Text} from 'react-native-animatable'; import {TouchableOpacity} from 'react-native-gesture-handler'; import LinearGradient from 'react-native-linear-gradient'; import {useDispatch, useSelector} from 'react-redux'; +import {BACKGROUND_GRADIENT_MAP} from '../../constants'; +import {BADGE_DATA} from '../../constants/badges'; +import {ERROR_BADGES_EXCEED_LIMIT} from '../../constants/strings'; import {MainStackParams} from '../../routes'; import { addBadgesService, getSuggestedPeopleProfile, updateBadgesService, } from '../../services'; -import {BACKGROUND_GRADIENT_MAP} from '../../constants'; -import {BADGE_DATA} from '../../constants/badges'; -import {ERROR_BADGES_EXCEED_LIMIT} from '../../constants/strings'; import {suggestedPeopleBadgesFinished} from '../../store/actions'; -import {BackgroundGradientType, UniversityType} from '../../types'; +import {RootState} from '../../store/rootReducer'; +import {BackgroundGradientType} from '../../types'; import {SCREEN_HEIGHT, StatusBarHeight} from '../../utils'; import BadgeList from './BadgeList'; import BadgeScreenHeader from './BadgeScreenHeader'; -import {useNavigation} from '@react-navigation/native'; -import {RootState} from '../../store/rootReducer'; /** * Home Screen for displaying Tagg Badge Selections diff --git a/src/screens/chat/ChatSearchBar.tsx b/src/screens/chat/ChatSearchBar.tsx index 4916ec45..d8aff567 100644 --- a/src/screens/chat/ChatSearchBar.tsx +++ b/src/screens/chat/ChatSearchBar.tsx @@ -26,7 +26,6 @@ const ChatSearchBar: React.FC<SearchBarProps> = ({ onChangeText, value, onCancel, - searching, animationProgress, onLayout, placeholder, @@ -53,7 +52,7 @@ const ChatSearchBar: React.FC<SearchBarProps> = ({ <Text style={styles.searchTextStyes}>To:</Text> </Animated.View> <TextInput - style={[styles.input]} + style={styles.input} placeholderTextColor={'#828282'} onSubmitEditing={handleSubmit} clearButtonMode="always" diff --git a/src/screens/main/NotificationsScreen.tsx b/src/screens/main/NotificationsScreen.tsx index 71199c9b..3efd9af8 100644 --- a/src/screens/main/NotificationsScreen.tsx +++ b/src/screens/main/NotificationsScreen.tsx @@ -1,6 +1,5 @@ import AsyncStorage from '@react-native-community/async-storage'; import {useFocusEffect, useNavigation} from '@react-navigation/native'; -import FindFriendsBlueIcon from '../../assets/icons/findFriends/find-friends-blue-icon.svg'; import moment from 'moment'; import React, {useCallback, useEffect, useState} from 'react'; import { @@ -18,12 +17,10 @@ import {checkPermission} from 'react-native-contacts'; import {TouchableOpacity} from 'react-native-gesture-handler'; import {SafeAreaView} from 'react-native-safe-area-context'; import {useDispatch, useSelector} from 'react-redux'; -import {PrivateAccountsPrompt} from '../../components/notifications/NotificationPrompts'; +import FindFriendsBlueIcon from '../../assets/icons/findFriends/find-friends-blue-icon.svg'; import {TabsGradient} from '../../components'; -import { - InviteFriendsPrompt, - Notification, -} from '../../components/notifications'; +import {Notification} from '../../components/notifications'; +import {PrivateAccountsPrompt} from '../../components/notifications/NotificationPrompts'; import { loadUserNotifications, updateNewNotificationReceived, diff --git a/src/screens/onboarding/OnboardingStepThree.tsx b/src/screens/onboarding/OnboardingStepThree.tsx index 5cf7993e..638f0889 100644 --- a/src/screens/onboarding/OnboardingStepThree.tsx +++ b/src/screens/onboarding/OnboardingStepThree.tsx @@ -61,7 +61,7 @@ const OnboardingStepThree: React.FC<OnboardingStepThreeProps> = ({ route, navigation, }) => { - const {userId, username} = route.params; + const {userId} = route.params; const [form, setForm] = React.useState<FormType>({ smallPic: '', university: UniversityType.Empty, @@ -135,7 +135,7 @@ const OnboardingStepThree: React.FC<OnboardingStepThreeProps> = ({ }; const handleClassYearUpdate = (value: string) => { - const classYear = Number.parseInt(value); + const classYear = parseInt(value, 10); setForm({ ...form, classYear, diff --git a/src/screens/onboarding/PasswordResetRequest.tsx b/src/screens/onboarding/PasswordResetRequest.tsx index 8a891bbb..8f987721 100644 --- a/src/screens/onboarding/PasswordResetRequest.tsx +++ b/src/screens/onboarding/PasswordResetRequest.tsx @@ -21,7 +21,7 @@ import { import {emailRegex, usernameRegex} from '../../constants'; import {OnboardingStackParams} from '../../routes'; import {handlePasswordResetRequest} from '../../services'; -import {BackgroundGradientType, VerificationScreenType} from '../../types'; +import {BackgroundGradientType} from '../../types'; type PasswordResetRequestRouteProp = RouteProp< OnboardingStackParams, diff --git a/src/screens/onboarding/legacy/ProfileOnboarding.tsx b/src/screens/onboarding/legacy/ProfileOnboarding.tsx index bf0863dc..e994c1e6 100644 --- a/src/screens/onboarding/legacy/ProfileOnboarding.tsx +++ b/src/screens/onboarding/legacy/ProfileOnboarding.tsx @@ -242,7 +242,7 @@ const ProfileOnboarding: React.FC<ProfileOnboardingProps> = ({ }; const handleClassYearUpdate = (value: string) => { - const classYear = Number.parseInt(value); + const classYear = parseInt(value, 10); setForm({ ...form, classYear, diff --git a/src/screens/onboarding/legacy/SocialMedia.tsx b/src/screens/onboarding/legacy/SocialMedia.tsx index db24830a..1f98401b 100644 --- a/src/screens/onboarding/legacy/SocialMedia.tsx +++ b/src/screens/onboarding/legacy/SocialMedia.tsx @@ -17,11 +17,7 @@ import { } from '../../../components'; import {SOCIAL_LIST} from '../../../constants'; import {OnboardingStackParams} from '../../../routes'; -import { - BackgroundGradientType, - CategorySelectionScreenType, - LinkerType, -} from '../../../types'; +import {BackgroundGradientType, LinkerType} from '../../../types'; /** * Social Media Screen for displaying social media linkers @@ -64,7 +60,6 @@ const SocialMedia: React.FC<SocialMediaProps> = ({route, navigation}) => { const handleNext = () => { navigation.navigate('CategorySelection', { - screenType: CategorySelectionScreenType.Onboarding, user: {userId: userId, username: username}, newCustomCategory: undefined, }); diff --git a/src/screens/onboarding/legacy/WaitlistSuccessScreen.tsx b/src/screens/onboarding/legacy/WaitlistSuccessScreen.tsx index 72bbec63..ad517814 100644 --- a/src/screens/onboarding/legacy/WaitlistSuccessScreen.tsx +++ b/src/screens/onboarding/legacy/WaitlistSuccessScreen.tsx @@ -1,5 +1,5 @@ import {StackNavigationProp} from '@react-navigation/stack'; -import * as React from 'react'; +import React from 'react'; import { KeyboardAvoidingView, Linking, diff --git a/src/screens/profile/CaptionScreen.tsx b/src/screens/profile/CaptionScreen.tsx index 282857d6..156ee41c 100644 --- a/src/screens/profile/CaptionScreen.tsx +++ b/src/screens/profile/CaptionScreen.tsx @@ -49,8 +49,8 @@ const CaptionScreen: React.FC<CaptionScreenProps> = ({route, navigation}) => { const [caption, setCaption] = useState(''); const [loading, setLoading] = useState(false); - const handleCaptionUpdate = (caption: string) => { - setCaption(caption); + const handleCaptionUpdate = (newCaption: string) => { + setCaption(newCaption); }; const navigateToProfile = () => { @@ -63,6 +63,9 @@ const CaptionScreen: React.FC<CaptionScreenProps> = ({route, navigation}) => { const handleShare = async () => { setLoading(true); + if (!image.filename) { + return; + } postMoment(image.filename, image.path, caption, title, userId).then( (data) => { setLoading(false); @@ -88,7 +91,7 @@ const CaptionScreen: React.FC<CaptionScreenProps> = ({route, navigation}) => { <TouchableWithoutFeedback onPress={Keyboard.dismiss}> <KeyboardAvoidingView behavior={Platform.OS === 'ios' ? 'padding' : 'height'} - style={{flex: 1}}> + style={styles.flex}> <View style={styles.contentContainer}> <View style={styles.buttonsContainer}> <Button @@ -157,6 +160,9 @@ const styles = StyleSheet.create({ paddingVertical: '1%', height: 60, }, + flex: { + flex: 1, + }, }); export default CaptionScreen; diff --git a/src/screens/profile/EditProfile.tsx b/src/screens/profile/EditProfile.tsx index 8b658043..26802e45 100644 --- a/src/screens/profile/EditProfile.tsx +++ b/src/screens/profile/EditProfile.tsx @@ -199,12 +199,12 @@ const EditProfile: React.FC<EditProfileProps> = ({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<EditProfileProps> = ({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, }); } @@ -267,7 +267,7 @@ const EditProfile: React.FC<EditProfileProps> = ({route, navigation}) => { }; const handleClassYearUpdate = (value: string) => { - const classYear = Number.parseInt(value); + const classYear = parseInt(value, 10); setForm({ ...form, classYear, @@ -383,8 +383,8 @@ const EditProfile: React.FC<EditProfileProps> = ({route, navigation}) => { headerRight: () => ( <Button title={'Save'} - buttonStyle={{backgroundColor: 'transparent', marginRight: 15}} - titleStyle={{fontWeight: 'bold'}} + buttonStyle={styles.headerRightButton} + titleStyle={styles.boldFont} onPress={() => { setLoading(true); handleSubmit().then(() => setLoading(false)); @@ -409,22 +409,13 @@ const EditProfile: React.FC<EditProfileProps> = ({route, navigation}) => { alwaysBounceVertical contentContainerStyle={{paddingBottom: SCREEN_HEIGHT / 15}}> <StatusBar barStyle="light-content" translucent={false} /> - <View - style={{ - position: 'relative', - alignSelf: 'center', - }}> + <View style={styles.relativeCenter}> <View> <View style={styles.profile}> <LargeProfilePic /> <SmallProfilePic /> </View> - <View - style={{ - position: 'relative', - width: 280, - alignSelf: 'center', - }}> + <View style={styles.relativeCenterWithWidth}> <TaggInput accessibilityHint="Enter a website." accessibilityLabel="Website input field." @@ -540,7 +531,7 @@ const EditProfile: React.FC<EditProfileProps> = ({route, navigation}) => { <SocialIcon social={'TikTok'} style={styles.icon} - screenType={ScreenType.Profile} + whiteRing={undefined} /> <View style={styles.taggInput}> <TaggInput @@ -631,20 +622,6 @@ const styles = StyleSheet.create({ width: 110, borderRadius: 55, }, - submitBtn: { - backgroundColor: '#8F01FF', - justifyContent: 'center', - alignItems: 'center', - width: 150, - height: 40, - borderRadius: 5, - marginTop: '5%', - }, - submitBtnLabel: { - fontSize: 16, - fontWeight: '500', - color: '#fff', - }, customGenderInput: { width: '100%', height: 40, @@ -666,7 +643,26 @@ const styles = StyleSheet.create({ aspectRatio: 1, flex: 1, }, - taggInput: {flex: 6.5, marginLeft: '3%'}, + taggInput: { + flex: 6.5, + marginLeft: '3%', + }, + headerRightButton: { + backgroundColor: 'transparent', + marginRight: 15, + }, + boldFont: { + fontWeight: 'bold', + }, + relativeCenter: { + position: 'relative', + alignSelf: 'center', + }, + relativeCenterWithWidth: { + position: 'relative', + width: 280, + alignSelf: 'center', + }, }); export default EditProfile; diff --git a/src/screens/profile/FriendsListScreen.tsx b/src/screens/profile/FriendsListScreen.tsx index 886ab9c4..1d10bc86 100644 --- a/src/screens/profile/FriendsListScreen.tsx +++ b/src/screens/profile/FriendsListScreen.tsx @@ -1,12 +1,6 @@ import {RouteProp} from '@react-navigation/native'; import React from 'react'; -import { - SafeAreaView, - ScrollView, - StatusBar, - StyleSheet, - View, -} from 'react-native'; +import {SafeAreaView, ScrollView, StatusBar, StyleSheet} from 'react-native'; import {useSelector} from 'react-redux'; import {Friends, TabsGradient} from '../../components'; import {MainStackParams} from '../../routes'; @@ -24,9 +18,9 @@ interface FriendsListScreenProps { const FriendsListScreen: React.FC<FriendsListScreenProps> = ({route}) => { const {userXId, screenType} = route.params; - const {friends} = userXId - ? useSelector((state: RootState) => state.userX[screenType][userXId]) - : useSelector((state: RootState) => state.friends); + const {friends} = useSelector((state: RootState) => + userXId ? state.userX[screenType][userXId] : state.friends, + ); return ( <> diff --git a/src/screens/profile/SocialMediaTaggs.tsx b/src/screens/profile/SocialMediaTaggs.tsx index 466ba509..9186f187 100644 --- a/src/screens/profile/SocialMediaTaggs.tsx +++ b/src/screens/profile/SocialMediaTaggs.tsx @@ -3,6 +3,7 @@ import {StackNavigationProp} from '@react-navigation/stack'; import React, {useEffect, useState} from 'react'; import {ScrollView, StatusBar, StyleSheet, View} from 'react-native'; import LinearGradient from 'react-native-linear-gradient'; +import {useSelector} from 'react-redux'; import { AvatarTitle, SocialMediaInfo, @@ -10,26 +11,17 @@ import { TaggPost, TwitterTaggPost, } from '../../components'; +import TaggLoadingIndicator from '../../components/common/TaggLoadingIndicator'; import {AVATAR_GRADIENT} from '../../constants'; -import {ProfileStackParams} from '../../routes'; -import { - SimplePostType, - TwitterPostType, - SocialAccountType, - ScreenType, -} from '../../types'; -import {AvatarHeaderHeight, SCREEN_HEIGHT} from '../../utils'; -import {useSelector} from 'react-redux'; +import {MainStackParams} from '../../routes'; import {RootState} from '../../store/rootReducer'; -import TaggLoadingIndicator from '../../components/common/TaggLoadingIndicator'; +import {SimplePostType, SocialAccountType, TwitterPostType} from '../../types'; +import {AvatarHeaderHeight, SCREEN_HEIGHT} from '../../utils'; -type SocialMediaTaggsRouteProp = RouteProp< - ProfileStackParams, - 'SocialMediaTaggs' ->; +type SocialMediaTaggsRouteProp = RouteProp<MainStackParams, 'SocialMediaTaggs'>; type SocialMediaTaggsNavigationProp = StackNavigationProp< - ProfileStackParams, + MainStackParams, 'SocialMediaTaggs' >; @@ -49,13 +41,13 @@ const SocialMediaTaggs: React.FC<SocialMediaTaggsProps> = ({ const { avatar, profile: {name}, - } = userXId - ? useSelector((state: RootState) => state.userX[screenType][userXId]) - : useSelector((state: RootState) => state.user); + } = useSelector((state: RootState) => + userXId ? state.userX[screenType][userXId] : state.user, + ); - const {socialAccounts} = userXId - ? useSelector((state: RootState) => state.userX[screenType][userXId]) - : useSelector((state: RootState) => state.socialAccounts); + const {socialAccounts} = useSelector((state: RootState) => + userXId ? state.userX[screenType][userXId] : state.socialAccounts, + ); useEffect(() => { const currentSocialData = {...socialAccounts[socialMediaType]}; @@ -67,7 +59,7 @@ const SocialMediaTaggs: React.FC<SocialMediaTaggsProps> = ({ useEffect(() => { navigation.setOptions({ headerTitle: () => { - return <AvatarTitle avatar={avatar} />; + return <AvatarTitle avatar={avatar ?? null} />; }, }); }, [avatar, navigation]); @@ -114,7 +106,7 @@ const SocialMediaTaggs: React.FC<SocialMediaTaggsProps> = ({ <TabsGradient /> </View> ) : ( - <TaggLoadingIndicator color="white" /> + <TaggLoadingIndicator /> )} </LinearGradient> ); diff --git a/src/screens/search/RequestContactsAccess.tsx b/src/screens/search/RequestContactsAccess.tsx index f5d2de1a..4b583349 100644 --- a/src/screens/search/RequestContactsAccess.tsx +++ b/src/screens/search/RequestContactsAccess.tsx @@ -60,7 +60,7 @@ const RequestContactsAccess: React.FC = () => { useAngle={true} angle={154.72} angleCenter={{x: 0.5, y: 0.5}} - style={{flex: 1}}> + style={styles.flex}> <SafeAreaView> <View style={{height: SCREEN_HEIGHT}}> <Animated.ScrollView @@ -201,5 +201,8 @@ const styles = StyleSheet.create({ lineHeight: normalize(20), color: '#fff', }, + flex: { + flex: 1, + }, }); export default RequestContactsAccess; diff --git a/src/screens/suggestedPeople/SPBody.tsx b/src/screens/suggestedPeople/SPBody.tsx index fa69d812..c22f8143 100644 --- a/src/screens/suggestedPeople/SPBody.tsx +++ b/src/screens/suggestedPeople/SPBody.tsx @@ -14,7 +14,6 @@ import { UniversityBadge, } from '../../types'; import {isIPhoneX, normalize, SCREEN_HEIGHT, SCREEN_WIDTH} from '../../utils'; -import {useSharedValue} from 'react-native-reanimated'; interface SPBodyProps { item: SuggestedPeopleDataType; diff --git a/src/screens/suggestedPeople/SuggestedPeopleScreen.tsx b/src/screens/suggestedPeople/SuggestedPeopleScreen.tsx index d6812f41..388a1ba7 100644 --- a/src/screens/suggestedPeople/SuggestedPeopleScreen.tsx +++ b/src/screens/suggestedPeople/SuggestedPeopleScreen.tsx @@ -24,7 +24,6 @@ import SPBody from './SPBody'; const SuggestedPeopleScreen: React.FC = () => { const navigation = useNavigation(); - const state: RootState = useStore().getState(); const dispatch = useDispatch(); const screenType = ScreenType.SuggestedPeople; const {suggested_people_linked} = useSelector( @@ -35,6 +34,7 @@ const SuggestedPeopleScreen: React.FC = () => { ); const {suggestedPeopleImage} = useSelector((state: RootState) => state.user); const [people, setPeople] = useState<SuggestedPeopleDataType[]>([]); + const state: RootState = useStore().getState(); const [displayedUser, setDisplayedUser] = useState<SuggestedPeopleDataType>(); const [page, setPage] = useState(0); const [refreshing, setRefreshing] = useState(false); diff --git a/src/services/UserProfileService.ts b/src/services/UserProfileService.ts index a2237c94..c11d874f 100644 --- a/src/services/UserProfileService.ts +++ b/src/services/UserProfileService.ts @@ -1,8 +1,6 @@ import AsyncStorage from '@react-native-community/async-storage'; import moment from 'moment'; -import {useEffect} from 'react'; import {Alert} from 'react-native'; -import {loadUserData} from '../store/actions'; import { EDIT_PROFILE_ENDPOINT, GET_FB_POSTS_ENDPOINT, @@ -31,6 +29,7 @@ import { SUCCESS_PWD_RESET, SUCCESS_VERIFICATION_CODE_SENT, } from '../constants/strings'; +import {loadUserData} from '../store/actions'; import { ProfileInfoType, ProfileType, @@ -113,7 +112,6 @@ export const updateProfileVisibility = async ( ); } } catch (error) { - debugger; Alert.alert(ERROR_PROFILE_UPDATE_SHORT, ERROR_DOUBLE_CHECK_CONNECTION); return { name: 'Profile update error', @@ -182,7 +180,7 @@ export const handlePasswordResetRequest = async (value: string) => { ); return true; } else { - if (status == 404) { + if (status === 404) { Alert.alert( `Please make sure that the email / username entered is registered with us. You may contact our customer support at ${TAGG_CUSTOMER_SUPPORT}`, ); @@ -216,7 +214,7 @@ export const handlePasswordCodeVerification = async ( if (status === 200) { return true; } else { - if (status == 404) { + if (status === 404) { Alert.alert(ERROR_PWD_ACCOUNT(TAGG_CUSTOMER_SUPPORT)); } else if (status === 401) { Alert.alert(ERROR_INVALID_PWD_CODE); @@ -248,9 +246,9 @@ export const handlePasswordReset = async (value: string, password: string) => { Alert.alert(SUCCESS_PWD_RESET); return true; } else { - if (status == 404) { + if (status === 404) { Alert.alert(ERROR_PWD_ACCOUNT(TAGG_CUSTOMER_SUPPORT)); - } else if (status == 406) { + } else if (status === 406) { Alert.alert(ERROR_DUP_OLD_PWD); } else { Alert.alert(ERROR_SOMETHING_WENT_WRONG_REFRESH); diff --git a/src/store/actions/user.ts b/src/store/actions/user.ts index c7d0d5a7..3ebd4190 100644 --- a/src/store/actions/user.ts +++ b/src/store/actions/user.ts @@ -233,4 +233,3 @@ export const suggestedPeopleAnimatedTutorialFinished = ( console.log('Error while updating suggested people linked state: ', error); } }; - diff --git a/src/store/actions/userBlock.ts b/src/store/actions/userBlock.ts index f903e99e..be6f9331 100644 --- a/src/store/actions/userBlock.ts +++ b/src/store/actions/userBlock.ts @@ -1,9 +1,9 @@ -import {RootState} from '../rootReducer'; -import {ProfilePreviewType, UserType} from '../../types/types'; -import {blockOrUnblockUser, loadBlockedUsers} from '../../services'; import {Action, ThunkAction} from '@reduxjs/toolkit'; -import {userBlockFetched, updateBlockedList, userLoggedIn} from '../reducers'; +import {blockOrUnblockUser, loadBlockedUsers} from '../../services'; +import {ProfilePreviewType, UserType} from '../../types/types'; import {getTokenOrLogout} from '../../utils'; +import {updateBlockedList, userBlockFetched} from '../reducers'; +import {RootState} from '../rootReducer'; export const loadBlockedList = ( userId: string, diff --git a/src/store/reducers/userBlockReducer.ts b/src/store/reducers/userBlockReducer.ts index 64bdda30..68b9a544 100644 --- a/src/store/reducers/userBlockReducer.ts +++ b/src/store/reducers/userBlockReducer.ts @@ -15,7 +15,7 @@ const userBlockSlice = createSlice({ state.blockedUsers.push(data); } else { state.blockedUsers = state.blockedUsers.filter( - (user) => user.username != data.username, + (user) => user.username !== data.username, ); } }, diff --git a/src/utils/common.ts b/src/utils/common.ts index 7ae36dc6..cec0e1b5 100644 --- a/src/utils/common.ts +++ b/src/utils/common.ts @@ -73,8 +73,8 @@ export const moveCategory: ( }; export const checkImageUploadStatus = (statusMap: object) => { - for (let [key, value] of Object.entries(statusMap)) { - if (value != 'Success') { + for (const value of Object.values(statusMap)) { + if (value !== 'Success') { return false; } } diff --git a/src/utils/friends.ts b/src/utils/friends.ts index 5b0ded8f..93d9e054 100644 --- a/src/utils/friends.ts +++ b/src/utils/friends.ts @@ -1,7 +1,12 @@ // Handles click on friend/requested/unfriend button import {RootState} from '../store/rootReducer'; -import {ProfilePreviewType, ProfileInfoType, ScreenType, UserType} from '../types'; +import { + ProfilePreviewType, + ProfileInfoType, + ScreenType, + UserType, +} from '../types'; import {AppDispatch} from '../store/configureStore'; import { addFriend, diff --git a/src/utils/hooks.ts b/src/utils/hooks.ts index 3914ef48..336ac26c 100644 --- a/src/utils/hooks.ts +++ b/src/utils/hooks.ts @@ -4,10 +4,10 @@ import {useEffect, useState} from 'react'; export const useAsyncStorage = (key: string, defaultValue: string) => { const [storedValue, setStoredValue] = useState<string>(defaultValue); - const getStoredItem = async (key: string, defaultValue: string) => { + const getStoredItem = async (currentKey: string, currentValue: string) => { try { - const item = await AsyncStorage.getItem(key); - const value = item ? item : defaultValue; + const item = await AsyncStorage.getItem(currentKey); + const value = item ? item : currentValue; setStoredValue(value); } catch (error) { console.log(error); |