aboutsummaryrefslogtreecommitdiff
path: root/src/components/profile/Friends.tsx
diff options
context:
space:
mode:
authorShravya Ramesh <shravs1208@gmail.com>2021-03-18 13:44:19 -0700
committerShravya Ramesh <shravs1208@gmail.com>2021-03-18 13:44:19 -0700
commitf81a4e1a05ca3fa66c2798b047d4bfd6995f462d (patch)
treefe9507ce9fe8076d12cbf53da576bedcd46c65a5 /src/components/profile/Friends.tsx
parenta44e8d02c117783c19618d3af204299ae5c7a9ff (diff)
Support modified endpoints + refactoring
Diffstat (limited to 'src/components/profile/Friends.tsx')
-rw-r--r--src/components/profile/Friends.tsx23
1 files changed, 8 insertions, 15 deletions
diff --git a/src/components/profile/Friends.tsx b/src/components/profile/Friends.tsx
index 36e0ef8a..7d57177c 100644
--- a/src/components/profile/Friends.tsx
+++ b/src/components/profile/Friends.tsx
@@ -9,7 +9,12 @@ import {usersFromContactsService} from '../../services';
import {NO_USER} from '../../store/initialStates';
import {RootState} from '../../store/rootReducer';
import {ProfilePreviewType, ScreenType} from '../../types';
-import {normalize, SCREEN_HEIGHT, SCREEN_WIDTH} from '../../utils';
+import {
+ extractContacts,
+ normalize,
+ SCREEN_HEIGHT,
+ SCREEN_WIDTH,
+} from '../../utils';
import {handleAddFriend, handleUnfriend} from '../../utils/friends';
import {ProfilePreview} from '../profile';
import FindFriendsBlueIcon from '../../assets/icons/findFriends/find-friends-blue-icon.svg';
@@ -31,24 +36,12 @@ const Friends: React.FC<FriendsProps> = ({result, screenType, userId}) => {
ProfilePreviewType[]
>([]);
- const extractPhoneNumbers = async () => {
- let phoneNumbers: Array<string> = [];
- await getAll().then((contacts) => {
- contacts.map((contact) => {
- contact.phoneNumbers.map(async (phoneNumber) => {
- phoneNumbers.push(await phoneNumber.number);
- });
- });
- });
- return phoneNumbers;
- };
-
useEffect(() => {
const handleFindFriends = () => {
- extractPhoneNumbers().then(async (phoneNumbers) => {
+ extractContacts().then(async (contacts) => {
const permission = await checkPermission();
if (permission === 'authorized') {
- let response = await usersFromContactsService(phoneNumbers);
+ let response = await usersFromContactsService(contacts);
await setUsersFromContacts(response.existing_tagg_users);
usersFromContacts.map((user) => console.log('user: ', user.username));
} else if (permission === 'undefined') {