diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/constants/strings.ts | 2 | ||||
-rw-r--r-- | src/routes/main/MainStackScreen.tsx | 22 | ||||
-rw-r--r-- | src/screens/profile/CaptionScreen.tsx | 2 | ||||
-rw-r--r-- | src/screens/search/RequestContactsAccess.tsx | 28 |
4 files changed, 35 insertions, 19 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 aec860f2..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'; @@ -50,15 +50,23 @@ const MainStackScreen: React.FC<MainStackProps> = ({route}) => { const isSearchTab = screenType === ScreenType.Search; const isNotificationsTab = screenType === ScreenType.Notifications; const isSuggestedPeopleTab = screenType === ScreenType.SuggestedPeople; - - AsyncStorage.getItem('respondedToAccessContacts').then((value) => - setRespondedToAccessContacts(value ? value : 'false'), - ); - const [respondedToAccessContacts, setRespondedToAccessContacts] = useState( - 'false', + 'true', ); + const loadResponseToAccessContacts = () => { + AsyncStorage.getItem('respondedToAccessContacts') + .then((value) => { + setRespondedToAccessContacts(value ? value : 'false'); + }) + .catch((error) => { + console.log('Something went wrong', error); + setRespondedToAccessContacts('true'); + }); + }; + + loadResponseToAccessContacts(); + const initialRouteName = (() => { switch (screenType) { case ScreenType.Profile: diff --git a/src/screens/profile/CaptionScreen.tsx b/src/screens/profile/CaptionScreen.tsx index 91aaa617..01e859ba 100644 --- a/src/screens/profile/CaptionScreen.tsx +++ b/src/screens/profile/CaptionScreen.tsx @@ -13,7 +13,7 @@ import { } from 'react-native'; import {Button} from 'react-native-elements'; import {useDispatch, useSelector} from 'react-redux'; -import {MainStackParams} from 'src/routes'; +import {MainStackParams} from '../../routes'; import {SearchBackground, TaggBigInput} from '../../components'; import {CaptionScreenHeader} from '../../components/'; import TaggLoadingIndicator from '../../components/common/TaggLoadingIndicator'; diff --git a/src/screens/search/RequestContactsAccess.tsx b/src/screens/search/RequestContactsAccess.tsx index de023464..08548c69 100644 --- a/src/screens/search/RequestContactsAccess.tsx +++ b/src/screens/search/RequestContactsAccess.tsx @@ -21,21 +21,29 @@ const RequestContactsAccess: React.FC = () => { const navigation = useNavigation(); const handleAllowAccess = async () => { - checkPermission().then((permission) => { + try { + let permission = await checkPermission(); if (permission === 'undefined') { - requestPermission().then((response) => { - if (response === 'authorized' || response === 'denied') { - navigation.navigate('Search'); - } - }); + await requestPermission(); } - }); - await AsyncStorage.setItem('respondedToAccessContacts', 'true'); + await AsyncStorage.setItem('respondedToAccessContacts', 'true'); + navigation.navigate('Search'); + } catch (err) { + console.log( + 'Unable to check and request permission to get access to user contacts', + ); + } }; const handleDontAllowAccess = async () => { - await AsyncStorage.setItem('respondedToAccessContacts', 'true'); - navigation.navigate('Search'); + try { + await AsyncStorage.setItem('respondedToAccessContacts', 'true'); + navigation.navigate('Search'); + } catch (err) { + console.log( + 'Unable to check and request permission to get access to user contacts', + ); + } }; return ( |