From 69c07634befdad4be416df843ecb803e760c5883 Mon Sep 17 00:00:00 2001 From: Ivan Chen Date: Tue, 11 May 2021 15:10:02 -0400 Subject: cleaned up dead code --- src/components/profile/Friends.tsx | 79 +++----------------------------------- 1 file changed, 6 insertions(+), 73 deletions(-) (limited to 'src/components/profile') diff --git a/src/components/profile/Friends.tsx b/src/components/profile/Friends.tsx index c9d8e6ae..f800597b 100644 --- a/src/components/profile/Friends.tsx +++ b/src/components/profile/Friends.tsx @@ -1,102 +1,35 @@ -import React, {useEffect, useState} from 'react'; +import React from 'react'; import {ScrollView, StyleSheet, Text, View} from 'react-native'; -import {checkPermission} from 'react-native-contacts'; import {TouchableOpacity} from 'react-native-gesture-handler'; import {useDispatch, useStore} from 'react-redux'; import {TAGG_LIGHT_BLUE} from '../../constants'; -import {usersFromContactsService} from '../../services'; import {NO_USER} from '../../store/initialStates'; import {RootState} from '../../store/rootReducer'; import {ProfilePreviewType, ScreenType} from '../../types'; -import { - extractContacts, - normalize, - SCREEN_HEIGHT, - SCREEN_WIDTH, -} from '../../utils'; -import {handleAddFriend, handleUnfriend} from '../../utils/friends'; +import {normalize, SCREEN_HEIGHT, SCREEN_WIDTH} from '../../utils'; +import {handleUnfriend} from '../../utils/friends'; import {ProfilePreview} from '../profile'; interface FriendsProps { result: Array; screenType: ScreenType; userId: string | undefined; - hideSubheader?: boolean; + hideFriendsFeature?: boolean; } const Friends: React.FC = ({ result, screenType, userId, - hideSubheader, + hideFriendsFeature, }) => { const state: RootState = useStore().getState(); const dispatch = useDispatch(); const {user: loggedInUser = NO_USER} = state.user; - const [usersFromContacts, setUsersFromContacts] = useState< - ProfilePreviewType[] - >([]); - - useEffect(() => { - const handleFindFriends = () => { - extractContacts().then(async (contacts) => { - const permission = await checkPermission(); - if (permission === 'authorized') { - let response = await usersFromContactsService(contacts); - setUsersFromContacts(response.existing_tagg_users); - } else { - console.log('Authorize access to contacts'); - } - }); - }; - handleFindFriends(); - }, []); - - const UsersFromContacts = () => ( - <> - {usersFromContacts?.splice(0, 2).map((profilePreview) => ( - - - - - { - handleAddFriend(screenType, profilePreview, dispatch, state).then( - (success) => { - if (success) { - let users = usersFromContacts; - setUsersFromContacts( - users.filter( - (user) => user.username !== profilePreview.username, - ), - ); - } - }, - ); - }}> - Add Friend - - - ))} - - ); return ( <> - {loggedInUser.userId === userId && usersFromContacts.length !== 0 && ( - - - Contacts on Tagg - - - - )} - {!hideSubheader && ( + {!hideFriendsFeature && ( Friends -- cgit v1.2.3-70-g09d2