mirror of
https://github.com/netzbegruenung/jitsi-meet-electron.git
synced 2024-05-01 16:24:53 +02:00
Bundle external API
We use very little functionality of it anyway.
This commit is contained in:
parent
d12611d79c
commit
c4aefb05b5
|
@ -11,8 +11,8 @@ import config from '../../config';
|
||||||
import { getSetting, setEmail, setName } from '../../settings';
|
import { getSetting, setEmail, setName } from '../../settings';
|
||||||
|
|
||||||
import { conferenceEnded, conferenceJoined } from '../actions';
|
import { conferenceEnded, conferenceJoined } from '../actions';
|
||||||
|
import JitsiMeetExternalAPI from '../external_api';
|
||||||
import { LoadingIndicator, Wrapper } from '../styled';
|
import { LoadingIndicator, Wrapper } from '../styled';
|
||||||
import { getExternalApiURL } from '../../utils';
|
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
|
|
||||||
|
@ -118,7 +118,6 @@ class Conference extends Component<Props, State> {
|
||||||
* @returns {void}
|
* @returns {void}
|
||||||
*/
|
*/
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
const parentNode = this._ref.current;
|
|
||||||
const room = this.props.location.state.room;
|
const room = this.props.location.state.room;
|
||||||
const serverTimeout = this.props._serverTimeout || config.defaultServerTimeout;
|
const serverTimeout = this.props._serverTimeout || config.defaultServerTimeout;
|
||||||
const serverURL = this.props.location.state.serverURL
|
const serverURL = this.props.location.state.serverURL
|
||||||
|
@ -130,15 +129,7 @@ class Conference extends Component<Props, State> {
|
||||||
serverURL
|
serverURL
|
||||||
};
|
};
|
||||||
|
|
||||||
const script = document.createElement('script');
|
this._loadConference();
|
||||||
|
|
||||||
script.async = true;
|
|
||||||
script.onload = () => this._onScriptLoad(parentNode);
|
|
||||||
script.onerror = (event: Event) =>
|
|
||||||
this._navigateToHome(event, room, serverURL);
|
|
||||||
script.src = getExternalApiURL(serverURL);
|
|
||||||
|
|
||||||
this._ref.current.appendChild(script);
|
|
||||||
|
|
||||||
// Set a timer for a timeout duration, if we haven't loaded the iframe by then,
|
// Set a timer for a timeout duration, if we haven't loaded the iframe by then,
|
||||||
// give up.
|
// give up.
|
||||||
|
@ -200,45 +191,12 @@ class Conference extends Component<Props, State> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* It renders a loading indicator, if appropriate.
|
* Load the conference by creating the iframe element in this component
|
||||||
|
* and attaching utils from jitsi-meet-electron-utils.
|
||||||
*
|
*
|
||||||
* @returns {?ReactElement}
|
|
||||||
*/
|
|
||||||
_maybeRenderLoadingIndicator() {
|
|
||||||
if (this.state.isLoading) {
|
|
||||||
return (
|
|
||||||
<LoadingIndicator>
|
|
||||||
<Spinner size = 'large' />
|
|
||||||
</LoadingIndicator>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 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}
|
* @returns {void}
|
||||||
*/
|
*/
|
||||||
_navigateToHome(event: Event, room: ?string, serverURL: ?string) {
|
_loadConference() {
|
||||||
this.props.dispatch(push('/', {
|
|
||||||
error: event.type === 'error',
|
|
||||||
room,
|
|
||||||
serverURL
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* When the script is loaded create the iframe element in this component
|
|
||||||
* and attach utils from jitsi-meet-electron-utils.
|
|
||||||
*
|
|
||||||
* @param {Object} parentNode - Node to which iframe has to be attached.
|
|
||||||
* @returns {void}
|
|
||||||
*/
|
|
||||||
_onScriptLoad(parentNode: Object) {
|
|
||||||
const JitsiMeetExternalAPI = window.JitsiMeetExternalAPI;
|
|
||||||
const url = new URL(this._conference.room, this._conference.serverURL);
|
const url = new URL(this._conference.room, this._conference.serverURL);
|
||||||
const roomName = url.pathname.split('/').pop();
|
const roomName = url.pathname.split('/').pop();
|
||||||
const host = this._conference.serverURL.replace(/https?:\/\//, '');
|
const host = this._conference.serverURL.replace(/https?:\/\//, '');
|
||||||
|
@ -253,7 +211,7 @@ class Conference extends Component<Props, State> {
|
||||||
const options = {
|
const options = {
|
||||||
configOverwrite,
|
configOverwrite,
|
||||||
onload: this._onIframeLoad,
|
onload: this._onIframeLoad,
|
||||||
parentNode,
|
parentNode: this._ref.current,
|
||||||
roomName
|
roomName
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -296,6 +254,37 @@ class Conference extends Component<Props, State> {
|
||||||
setupPowerMonitorRender(this._api);
|
setupPowerMonitorRender(this._api);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* It renders a loading indicator, if appropriate.
|
||||||
|
*
|
||||||
|
* @returns {?ReactElement}
|
||||||
|
*/
|
||||||
|
_maybeRenderLoadingIndicator() {
|
||||||
|
if (this.state.isLoading) {
|
||||||
|
return (
|
||||||
|
<LoadingIndicator>
|
||||||
|
<Spinner size = 'large' />
|
||||||
|
</LoadingIndicator>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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(event: Event, room: ?string, serverURL: ?string) {
|
||||||
|
this.props.dispatch(push('/', {
|
||||||
|
error: event.type === 'error',
|
||||||
|
room,
|
||||||
|
serverURL
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
_onVideoConferenceEnded: (*) => void;
|
_onVideoConferenceEnded: (*) => void;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
4
app/features/conference/external_api.js
Normal file
4
app/features/conference/external_api.js
Normal file
File diff suppressed because one or more lines are too long
|
@ -21,6 +21,7 @@ module.exports = {
|
||||||
__dirname: true
|
__dirname: true
|
||||||
},
|
},
|
||||||
module: {
|
module: {
|
||||||
|
noParse: /external_api\\.js/,
|
||||||
rules: [
|
rules: [
|
||||||
{
|
{
|
||||||
exclude: /node_modules(?!(\/|\\)js-utils)/,
|
exclude: /node_modules(?!(\/|\\)js-utils)/,
|
||||||
|
|
Loading…
Reference in a new issue