diff options
author | Saúl Ibarra Corretgé <s@saghul.net> | 2018-09-23 10:49:17 +0200 |
---|---|---|
committer | Hristo Terezov <hristo@jitsi.org> | 2018-09-28 10:49:03 -0500 |
commit | cc91dae90bec637dd70aa20e5a4977be93da2ed4 (patch) | |
tree | 77f89b3c94a2277624f72337f558aefecec34c77 | |
parent | eec6a270c5b2c7c93891dee1f9b49cfd351f7cff (diff) |
Add a 10s join timeout
-rw-r--r-- | app/features/conference/components/Conference.js | 36 |
1 files changed, 31 insertions, 5 deletions
diff --git a/app/features/conference/components/Conference.js b/app/features/conference/components/Conference.js index 421f04c..a12a16b 100644 --- a/app/features/conference/components/Conference.js +++ b/app/features/conference/components/Conference.js @@ -78,11 +78,6 @@ type State = { */ class Conference extends Component<Props, State> { /** - * Reference to the element of this component. - */ - _ref: Object; - - /** * External API object. */ _api: Object; @@ -93,6 +88,16 @@ class Conference extends Component<Props, State> { _conference: Object; /** + * Timer to cancel the joining if it takes too long. + */ + _loadTimer: ?TimeoutID; + + /** + * Reference to the element of this component. + */ + _ref: Object; + + /** * Initializes a new {@code Conference} instance. * * @inheritdoc @@ -137,6 +142,19 @@ class Conference extends Component<Props, State> { script.src = getExternalApiURL(serverURL); this._ref.current.appendChild(script); + + // Set a timer for 10s, if we haven't joined by then, give up. + this._loadTimer = setTimeout(() => { + this._navigateToHome( + + // $FlowFixMe + { + error: 'Loading error', + type: 'error' + }, + room, + serverURL); + }, 10000); } /** @@ -165,6 +183,9 @@ class Conference extends Component<Props, State> { * @returns {void} */ componentWillUnmount() { + if (this._loadTimer) { + clearTimeout(this._loadTimer); + } if (this._api) { this._api.dispose(); } @@ -291,6 +312,11 @@ class Conference extends Component<Props, State> { * @returns {void} */ _onVideoConferenceJoined(conferenceInfo: Object) { + if (this._loadTimer) { + clearTimeout(this._loadTimer); + this._loadTimer = null; + } + this.setState({ isLoading: false }); |