55import React , { useEffect , useState } from 'react' ;
66import { View , StatusBar } from 'react-native' ;
77import { SafeAreaView } from 'react-native-safe-area-context' ;
8- import { useDispatch } from 'react-redux' ;
8+ import { useDispatch , useSelector } from 'react-redux' ;
99
1010import CustomInput from '../../Components/CustomInput' ;
1111import CustomButton from '../../Components/CustomButton' ;
@@ -18,12 +18,18 @@ import {useUtils} from '../../Utils/useUtils';
1818import {
1919 changeCallState ,
2020 toggleSendVideo ,
21+ setError ,
2122} from '../../Core/Store/conference/actions' ;
23+ import { clearErrors } from '../../Core/Store/global/actions' ;
24+ import { RootReducer } from '../../Core/Store' ;
2225
2326import styles from './styles' ;
2427
2528const MainScreen = ( { navigation} : IScreenProps < 'Main' > ) => {
2629 const dispatch = useDispatch ( ) ;
30+ const error = useSelector (
31+ ( store : RootReducer ) => store . conferenceReducer . error ,
32+ ) ;
2733 const {
2834 isIOS,
2935 isAndroid,
@@ -32,15 +38,14 @@ const MainScreen = ({navigation}: IScreenProps<'Main'>) => {
3238 } = useUtils ( ) ;
3339
3440 const [ conference , setConference ] = useState ( '' ) ;
35- const [ validationText , setValidationText ] = useState ( '' ) ;
3641
3742 useEffect ( ( ) => {
38- setValidationText ( '' ) ;
43+ error && dispatch ( clearErrors ( ) ) ;
3944 } , [ conference ] ) ;
4045
4146 const startConference = async ( withVideo ?: boolean ) => {
4247 if ( ! conference ) {
43- setValidationText ( 'Name cannot be empty') ;
48+ dispatch ( setError ( 'Room cannot be empty') ) ;
4449 return ;
4550 }
4651 if ( withVideo ) {
@@ -55,7 +60,7 @@ const MainScreen = ({navigation}: IScreenProps<'Main'>) => {
5560 resultVideo = await checkAndroidCameraPermission ( ) ;
5661 ! resultVideo && dispatch ( toggleSendVideo ( ) ) ;
5762 }
58- } catch ( error ) {
63+ } catch ( _ ) {
5964 console . warn ( 'Something was wrong with android permissions...' ) ;
6065 }
6166 }
@@ -76,7 +81,7 @@ const MainScreen = ({navigation}: IScreenProps<'Main'>) => {
7681 value = { conference }
7782 placeholder = { 'Type conference name here' }
7883 setValue = { setConference }
79- validationText = { validationText }
84+ validationText = { error }
8085 />
8186 < View style = { styles . settingsWrapper } >
8287 < CustomButton
0 commit comments