mirror of
https://gitcode.com/GitHub_Trending/ji/jitsi-meet.git
synced 2026-05-14 17:57:49 +00:00
Initializing UI features, like keyboard shortcuts, by chaining onto APP.conference.init is not safe because init can fail, skipping the initializing of UI features. This can happen when the room is locked and then a failure event is dispatched into middleware. I couldn't find a place to properly chain onto in the APP.conference.init promise chain, primarily due to the flow continued within middleware, so instead I leveraged an existing listener for CONFERENCE_JOINED.
64 lines
1.7 KiB
JavaScript
64 lines
1.7 KiB
JavaScript
/* @flow */
|
|
|
|
import type { Dispatch } from 'redux';
|
|
|
|
import {
|
|
libInitError,
|
|
WEBRTC_NOT_READY,
|
|
WEBRTC_NOT_SUPPORTED
|
|
} from '../lib-jitsi-meet';
|
|
|
|
declare var APP: Object;
|
|
declare var config: Object;
|
|
|
|
const logger = require('jitsi-meet-logger').getLogger(__filename);
|
|
|
|
export {
|
|
connectionEstablished,
|
|
connectionFailed,
|
|
setLocationURL
|
|
} from './actions.native';
|
|
|
|
/**
|
|
* Opens new connection.
|
|
*
|
|
* @returns {Promise<JitsiConnection>}
|
|
*/
|
|
export function connect() {
|
|
return (dispatch: Dispatch<*>, getState: Function) => {
|
|
const state = getState();
|
|
|
|
// XXX Lib-jitsi-meet does not accept uppercase letters.
|
|
const room = state['features/base/conference'].room.toLowerCase();
|
|
|
|
// XXX For web based version we use conference initialization logic
|
|
// from the old app (at the moment of writing).
|
|
return APP.conference.init({ roomName: room })
|
|
.catch(error => {
|
|
APP.API.notifyConferenceLeft(APP.conference.roomName);
|
|
logger.error(error);
|
|
|
|
// TODO The following are in fact Errors raised by
|
|
// JitsiMeetJS.init() which should be taken care of in
|
|
// features/base/lib-jitsi-meet but we are not there yet on the
|
|
// Web at the time of this writing.
|
|
switch (error.name) {
|
|
case WEBRTC_NOT_READY:
|
|
case WEBRTC_NOT_SUPPORTED:
|
|
dispatch(libInitError(error));
|
|
}
|
|
});
|
|
};
|
|
}
|
|
|
|
/**
|
|
* Closes connection.
|
|
*
|
|
* @returns {Function}
|
|
*/
|
|
export function disconnect() {
|
|
// XXX For web based version we use conference hanging up logic from the old
|
|
// app.
|
|
return () => APP.conference.hangup();
|
|
}
|