Skip to content

Commit

Permalink
Merge pull request #132 from voximplant/show_error
Browse files Browse the repository at this point in the history
Show error , when user trying connect to conference with wrong confId
  • Loading branch information
pe1ros authored Jun 15, 2022
2 parents f7b22a6 + 9c4de51 commit 4edd26e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
4 changes: 4 additions & 0 deletions ConferenceDemo/src/Core/Store/conference/reducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
IParticipant,
IReduxAction,
} from '../../../Utils/types';
import {globalActions} from '../global/actionTypes';
import {conferenceActions} from './actionTypes';

export interface IConferenceReducer {
Expand Down Expand Up @@ -35,6 +36,9 @@ const conferenceReducer = (
): IConferenceReducer => {
const {type, payload} = action;
switch (type) {
case globalActions.CLEAR_ERRORS: {
return {...state, error: ''};
}
case conferenceActions.TOGGLE_MUTE: {
return {...state, isMuted: !state.isMuted};
}
Expand Down
17 changes: 11 additions & 6 deletions ConferenceDemo/src/Screens/Main/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import React, {useEffect, useState} from 'react';
import {View, StatusBar} from 'react-native';
import {SafeAreaView} from 'react-native-safe-area-context';
import {useDispatch} from 'react-redux';
import {useDispatch, useSelector} from 'react-redux';

import CustomInput from '../../Components/CustomInput';
import CustomButton from '../../Components/CustomButton';
Expand All @@ -18,12 +18,18 @@ import {useUtils} from '../../Utils/useUtils';
import {
changeCallState,
toggleSendVideo,
setError,
} from '../../Core/Store/conference/actions';
import {clearErrors} from '../../Core/Store/global/actions';
import {RootReducer} from '../../Core/Store';

import styles from './styles';

const MainScreen = ({navigation}: IScreenProps<'Main'>) => {
const dispatch = useDispatch();
const error = useSelector(
(store: RootReducer) => store.conferenceReducer.error,
);
const {
isIOS,
isAndroid,
Expand All @@ -32,15 +38,14 @@ const MainScreen = ({navigation}: IScreenProps<'Main'>) => {
} = useUtils();

const [conference, setConference] = useState('');
const [validationText, setValidationText] = useState('');

useEffect(() => {
setValidationText('');
error && dispatch(clearErrors());
}, [conference]);

const startConference = async (withVideo?: boolean) => {
if (!conference) {
setValidationText('Name cannot be empty');
dispatch(setError('Room cannot be empty'));
return;
}
if (withVideo) {
Expand All @@ -55,7 +60,7 @@ const MainScreen = ({navigation}: IScreenProps<'Main'>) => {
resultVideo = await checkAndroidCameraPermission();
!resultVideo && dispatch(toggleSendVideo());
}
} catch (error) {
} catch (_) {
console.warn('Something was wrong with android permissions...');
}
}
Expand All @@ -76,7 +81,7 @@ const MainScreen = ({navigation}: IScreenProps<'Main'>) => {
value={conference}
placeholder={'Type conference name here'}
setValue={setConference}
validationText={validationText}
validationText={error}
/>
<View style={styles.settingsWrapper}>
<CustomButton
Expand Down

0 comments on commit 4edd26e

Please sign in to comment.