diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/constants/strings.ts | 2 | ||||
-rw-r--r-- | src/routes/main/MainStackScreen.tsx | 18 | ||||
-rw-r--r-- | src/screens/search/RequestContactsAccess.tsx | 22 |
3 files changed, 16 insertions, 26 deletions
diff --git a/src/constants/strings.ts b/src/constants/strings.ts index 5ae19e9c..353e0d02 100644 --- a/src/constants/strings.ts +++ b/src/constants/strings.ts @@ -25,7 +25,7 @@ export const ERROR_INVALID_VERIFICATION_CODE_FORMAT = 'Please enter the 6 digit export const ERROR_INVLAID_CODE = 'The code entered is not valid!'; export const ERROR_LINK = (str: string) => `Unable to link with ${str}, Please check your login and try again`; export const ERROR_LOGIN = 'There was a problem logging you in, please refresh and try again'; -export const ERROR_LOGIN_FAILED = 'Login failed. Check your username and passoword, and try again'; +export const ERROR_LOGIN_FAILED = 'Login failed. Check your username and password, and try again'; export const ERROR_NEXT_PAGE = 'There was a problem while loading the next page 😓, try again in a couple minutes'; export const ERROR_PROFILE_CREATION_SHORT = 'Profile creation failed 😓'; export const ERROR_PWD_ACCOUNT = (str: string) => `Please make sure that the email / username entered is registered with us. You may contact our customer support at ${str}`; diff --git a/src/routes/main/MainStackScreen.tsx b/src/routes/main/MainStackScreen.tsx index 5b3f1178..acf0cd28 100644 --- a/src/routes/main/MainStackScreen.tsx +++ b/src/routes/main/MainStackScreen.tsx @@ -1,7 +1,7 @@ import AsyncStorage from '@react-native-community/async-storage'; import {RouteProp} from '@react-navigation/native'; import {StackNavigationOptions} from '@react-navigation/stack'; -import React, {useState} from 'react'; +import React, {useEffect, useState} from 'react'; import {StyleSheet, Text} from 'react-native'; import {normalize} from 'react-native-elements'; import BackIcon from '../../assets/icons/back-arrow.svg'; @@ -51,20 +51,20 @@ const MainStackScreen: React.FC<MainStackProps> = ({route}) => { const isNotificationsTab = screenType === ScreenType.Notifications; const isSuggestedPeopleTab = screenType === ScreenType.SuggestedPeople; const [respondedToAccessContacts, setRespondedToAccessContacts] = useState( - 'false', + 'true', ); const loadResponseToAccessContacts = () => { - try { - AsyncStorage.getItem('respondedToAccessContacts').then((value) => { + AsyncStorage.getItem('respondedToAccessContacts') + .then((value) => { setRespondedToAccessContacts(value ? value : 'false'); + }) + .catch((error) => { + console.log('Something went wrong', error); + setRespondedToAccessContacts('true'); }); - } catch (err) { - console.log( - 'Unable to check and request permission to get access to user contacts', - ); - } }; + loadResponseToAccessContacts(); const initialRouteName = (() => { diff --git a/src/screens/search/RequestContactsAccess.tsx b/src/screens/search/RequestContactsAccess.tsx index 69de1ddf..08548c69 100644 --- a/src/screens/search/RequestContactsAccess.tsx +++ b/src/screens/search/RequestContactsAccess.tsx @@ -22,22 +22,12 @@ const RequestContactsAccess: React.FC = () => { const handleAllowAccess = async () => { try { - checkPermission().then((permission) => { - if (permission === 'undefined') { - requestPermission().then((response) => { - if (response === 'authorized' || response === 'denied') { - AsyncStorage.setItem( - 'respondedToAccessContacts', - 'true', - ).then(() => navigation.navigate('Search')); - } - }); - } else { - AsyncStorage.setItem('respondedToAccessContacts', 'true').then(() => - navigation.navigate('Search'), - ); - } - }); + let permission = await checkPermission(); + if (permission === 'undefined') { + await requestPermission(); + } + await AsyncStorage.setItem('respondedToAccessContacts', 'true'); + navigation.navigate('Search'); } catch (err) { console.log( 'Unable to check and request permission to get access to user contacts', |