Skip to content

Commit

Permalink
Display error when unable to join conference
Browse files Browse the repository at this point in the history
  • Loading branch information
akshitkrnagpal authored and saghul committed Jul 10, 2018
1 parent 921b7f6 commit 736f2ae
Show file tree
Hide file tree
Showing 4 changed files with 88 additions and 23 deletions.
20 changes: 13 additions & 7 deletions app/features/conference/components/Conference.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ class Conference extends Component<Props, State> {

this._ref = React.createRef();

this._navigateToHome = this._navigateToHome.bind(this);
this._onIframeLoad = this._onIframeLoad.bind(this);
}

Expand All @@ -121,7 +120,8 @@ class Conference extends Component<Props, State> {

script.async = true;
script.onload = () => this._onScriptLoad(parentNode, room, serverURL);
script.onerror = this._navigateToHome;
script.onerror = (event: Event) =>
this._navigateToHome(event, room, serverURL);
script.src = getExternalApiURL(serverURL);

this._ref.current.appendChild(script);
Expand Down Expand Up @@ -186,15 +186,20 @@ class Conference extends Component<Props, State> {
}
}

_navigateToHome: (*) => void;

/**
* Navigates to home screen (Welcome).
*
* @param {Event} event - Event by which the function is called.
* @param {string} room - Room name.
* @param {string} serverURL - Server URL.
* @returns {void}
*/
_navigateToHome() {
this.props.dispatch(push('/'));
_navigateToHome(event: Event, room: ?string, serverURL: ?string) {
this.props.dispatch(push('/', {
error: event.type === 'error',
room,
serverURL
}));
}

/**
Expand Down Expand Up @@ -231,7 +236,8 @@ class Conference extends Component<Props, State> {
setupAlwaysOnTopRender(this._api);
setupWiFiStats(iframe);

this._api.on('readyToClose', this._navigateToHome);
this._api.on('readyToClose', (event: Event) =>
this._navigateToHome(event));
this._api.on('videoConferenceJoined',
(conferenceInfo: Object) =>
this._onVideoConferenceJoined(conferenceInfo));
Expand Down
30 changes: 30 additions & 0 deletions app/features/welcome/components/Welcome.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ type Props = {
* Redux dispatch.
*/
dispatch: Dispatch<*>;

/**
* React Router location object.
*/
location: Object;
};

type State = {
Expand Down Expand Up @@ -55,12 +60,36 @@ class Welcome extends Component<Props, State> {
this._onJoin = this._onJoin.bind(this);
}

/**
* Initialize url value in state if passed using location state object.
*
* @param {Props} props - New props of the component.
* @returns {State} - New state of the component.
*/
static getDerivedStateFromProps(props) {
let url = '';

// Check and parse url if exists in location state.
if (props.location.state) {
const { room, serverURL } = props.location.state;

if (room && serverURL) {
url = `${serverURL}/${room}`;
}
}

// Return local state object having input url.
return { url };
}

/**
* Render function of component.
*
* @returns {ReactElement}
*/
render() {
const { state } = this.props.location;

return (
<Page navigation = { <Navbar /> }>
<AtlasKitThemeProvider mode = 'light'>
Expand All @@ -69,6 +98,7 @@ class Welcome extends Component<Props, State> {
<Form onSubmit = { this._onFormSubmit }>
<FieldTextStateless
autoFocus = { true }
isInvalid = { state && state.error }
isLabelHidden = { true }
onChange = { this._onURLChange }
shouldFitContainer = { true }
Expand Down
59 changes: 44 additions & 15 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@
"electron-window-state": "4.1.1",
"history": "4.7.2",
"jitsi-meet-electron-utils": "github:jitsi/jitsi-meet-electron-utils#1972c3bf0884ace68eb496894dabae593d6dbf49",
"mousetrap": "1.6.2",
"js-utils": "github:jitsi/js-utils#0c53500a5120be2aa3fc590f0f932a0d4771920f",
"mousetrap": "1.6.2",
"react": "16.3.2",
"react-dom": "16.3.2",
"react-redux": "5.0.7",
Expand Down

0 comments on commit 736f2ae

Please sign in to comment.