diff options
author | Ivan Chen <ivan@tagg.id> | 2021-04-20 18:01:40 -0400 |
---|---|---|
committer | Ivan Chen <ivan@tagg.id> | 2021-04-20 18:01:40 -0400 |
commit | bb1479dfcd8daad8ef2593d4ac65a0b1239a6139 (patch) | |
tree | ca3d73f914ccacb232f54011b7d6299984e17140 | |
parent | c4e76811cae6cf14d5cc8daed9317f808087ed77 (diff) |
linted
-rw-r--r-- | src/components/messages/ChatInput.tsx | 59 | ||||
-rw-r--r-- | src/screens/onboarding/CategorySelection.tsx | 4 | ||||
-rw-r--r-- | src/screens/onboarding/InvitationCodeVerification.tsx | 4 | ||||
-rw-r--r-- | src/screens/profile/EditProfile.tsx | 2 | ||||
-rw-r--r-- | src/screens/search/RequestContactsAccess.tsx | 5 | ||||
-rw-r--r-- | src/screens/suggestedPeople/SPBody.tsx | 1 | ||||
-rw-r--r-- | src/screens/suggestedPeople/SuggestedPeopleScreen.tsx | 2 | ||||
-rw-r--r-- | src/services/UserProfileService.ts | 12 | ||||
-rw-r--r-- | src/store/actions/userBlock.ts | 8 | ||||
-rw-r--r-- | src/store/reducers/userBlockReducer.ts | 2 | ||||
-rw-r--r-- | src/utils/common.ts | 4 | ||||
-rw-r--r-- | src/utils/hooks.ts | 6 |
12 files changed, 51 insertions, 58 deletions
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/screens/onboarding/CategorySelection.tsx b/src/screens/onboarding/CategorySelection.tsx index ab5ff3be..9d5fbe4d 100644 --- a/src/screens/onboarding/CategorySelection.tsx +++ b/src/screens/onboarding/CategorySelection.tsx @@ -1,6 +1,6 @@ import {RouteProp} from '@react-navigation/native'; import {StackNavigationProp} from '@react-navigation/stack'; -import React, {useContext, useEffect, useState} from 'react'; +import React, {useEffect, useState} from 'react'; import { Alert, Platform, @@ -12,7 +12,6 @@ import { } from 'react-native'; import {ScrollView} from 'react-native-gesture-handler'; import {useDispatch, useSelector} from 'react-redux'; -import {ChatContext} from '../../App'; import PlusIcon from '../../assets/icons/plus_icon-01.svg'; import {Background, MomentCategory} from '../../components'; import {MOMENT_CATEGORIES} from '../../constants'; @@ -50,7 +49,6 @@ const CategorySelection: React.FC<CategorySelectionProps> = ({ * Same component to be used for category selection while onboarding and while on profile */ const {screenType, user} = route.params; - const {chatClient} = useContext(ChatContext); const isOnBoarding: boolean = screenType === CategorySelectionScreenType.Onboarding; const {userId, username} = user; diff --git a/src/screens/onboarding/InvitationCodeVerification.tsx b/src/screens/onboarding/InvitationCodeVerification.tsx index 6bc0ac9d..e160b4b7 100644 --- a/src/screens/onboarding/InvitationCodeVerification.tsx +++ b/src/screens/onboarding/InvitationCodeVerification.tsx @@ -1,7 +1,7 @@ import AsyncStorage from '@react-native-community/async-storage'; import {RouteProp} from '@react-navigation/native'; import {StackNavigationProp} from '@react-navigation/stack'; -import React, {useContext} from 'react'; +import React from 'react'; import {Alert, KeyboardAvoidingView, StyleSheet, View} from 'react-native'; import {Text} from 'react-native-animatable'; import { @@ -27,7 +27,6 @@ import { import {OnboardingStackParams} from '../../routes'; import {BackgroundGradientType} from '../../types'; import {SCREEN_WIDTH, userLogin} from '../../utils'; -import {ChatContext} from '../../App'; type InvitationCodeVerificationRouteProp = RouteProp< OnboardingStackParams, @@ -59,7 +58,6 @@ const InvitationCodeVerification: React.FC<InvitationCodeVerificationProps> = ({ setValue, }); const dispatch = useDispatch(); - const {chatClient} = useContext(ChatContext); const handleInvitationCodeVerification = async () => { if (value.length === 6) { diff --git a/src/screens/profile/EditProfile.tsx b/src/screens/profile/EditProfile.tsx index 36abb146..26802e45 100644 --- a/src/screens/profile/EditProfile.tsx +++ b/src/screens/profile/EditProfile.tsx @@ -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, 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 1ce1d0b5..9e93d479 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, @@ -30,6 +28,7 @@ import { SUCCESS_PWD_RESET, SUCCESS_VERIFICATION_CODE_SENT, } from '../constants/strings'; +import {loadUserData} from '../store/actions'; import { ProfileInfoType, ProfileType, @@ -112,7 +111,6 @@ export const updateProfileVisibility = async ( ); } } catch (error) { - debugger; Alert.alert(ERROR_PROFILE_UPDATE_SHORT, ERROR_DOUBLE_CHECK_CONNECTION); return { name: 'Profile update error', @@ -181,7 +179,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}`, ); @@ -215,7 +213,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); @@ -247,9 +245,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/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/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); |