Skip to content

Commit 4edd26e

Browse files
authored
Merge pull request #132 from voximplant/show_error
Show error , when user trying connect to conference with wrong confId
2 parents f7b22a6 + 9c4de51 commit 4edd26e

2 files changed

Lines changed: 15 additions & 6 deletions

File tree

ConferenceDemo/src/Core/Store/conference/reducer.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
IParticipant,
88
IReduxAction,
99
} from '../../../Utils/types';
10+
import {globalActions} from '../global/actionTypes';
1011
import {conferenceActions} from './actionTypes';
1112

1213
export interface IConferenceReducer {
@@ -35,6 +36,9 @@ const conferenceReducer = (
3536
): IConferenceReducer => {
3637
const {type, payload} = action;
3738
switch (type) {
39+
case globalActions.CLEAR_ERRORS: {
40+
return {...state, error: ''};
41+
}
3842
case conferenceActions.TOGGLE_MUTE: {
3943
return {...state, isMuted: !state.isMuted};
4044
}

ConferenceDemo/src/Screens/Main/index.tsx

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import React, {useEffect, useState} from 'react';
66
import {View, StatusBar} from 'react-native';
77
import {SafeAreaView} from 'react-native-safe-area-context';
8-
import {useDispatch} from 'react-redux';
8+
import {useDispatch, useSelector} from 'react-redux';
99

1010
import CustomInput from '../../Components/CustomInput';
1111
import CustomButton from '../../Components/CustomButton';
@@ -18,12 +18,18 @@ import {useUtils} from '../../Utils/useUtils';
1818
import {
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

2326
import styles from './styles';
2427

2528
const 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

Comments
 (0)