From b1c88afecd72864fe928882fc64c767dc58076fe Mon Sep 17 00:00:00 2001 From: Shravya Ramesh Date: Thu, 18 Mar 2021 16:00:33 -0700 Subject: open settings --- src/components/profile/Friends.tsx | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/components/profile/Friends.tsx b/src/components/profile/Friends.tsx index 1c295c25..62ae2b48 100644 --- a/src/components/profile/Friends.tsx +++ b/src/components/profile/Friends.tsx @@ -1,6 +1,6 @@ import {useNavigation} from '@react-navigation/native'; import React, {useEffect, useState} from 'react'; -import {ScrollView, StyleSheet, Text, View} from 'react-native'; +import {Linking, ScrollView, StyleSheet, Text, View} from 'react-native'; import {checkPermission} from 'react-native-contacts'; import {TouchableOpacity} from 'react-native-gesture-handler'; import {useDispatch, useSelector, useStore} from 'react-redux'; @@ -43,11 +43,8 @@ const Friends: React.FC = ({result, screenType, userId}) => { if (permission === 'authorized') { let response = await usersFromContactsService(contacts); await setUsersFromContacts(response.existing_tagg_users); - usersFromContacts.map((user) => console.log('user: ', user.username)); - } else if (permission === 'undefined') { - navigation.navigate('RequestContactsAccess'); } else { - console.log('Go to settings'); + console.log('Authorize access to contacts'); } }); }; @@ -98,11 +95,16 @@ const Friends: React.FC = ({result, screenType, userId}) => { Add Friends - navigation.navigate('InviteFriendsScreen', { - screenType: ScreenType.Profile, - }) - }> + onPress={async () => { + const permission = await checkPermission(); + if (permission === 'authorized') { + navigation.navigate('InviteFriendsScreen', { + screenType: ScreenType.Profile, + }); + } else { + Linking.openSettings(); + } + }}> Find Friends -- cgit v1.2.3-70-g09d2