feat: pass network info to LJM

This commit is contained in:
paweldomas 2020-03-30 08:50:26 -05:00 committed by Paweł Domas
parent bfd5db355d
commit bc43f00d28
3 changed files with 25 additions and 1 deletions

View File

@ -2,6 +2,8 @@
import type { Dispatch } from 'redux'; import type { Dispatch } from 'redux';
import { isOnline } from '../net-info/selectors';
import JitsiMeetJS from './_'; import JitsiMeetJS from './_';
import { import {
LIB_DID_DISPOSE, LIB_DID_DISPOSE,
@ -37,7 +39,8 @@ export function disposeLib() {
*/ */
export function initLib() { export function initLib() {
return (dispatch: Dispatch<any>, getState: Function): void => { return (dispatch: Dispatch<any>, getState: Function): void => {
const config = getState()['features/base/config']; const state = getState();
const config = state['features/base/config'];
if (!config) { if (!config) {
throw new Error('Cannot init lib-jitsi-meet without config'); throw new Error('Cannot init lib-jitsi-meet without config');
@ -50,6 +53,9 @@ export function initLib() {
enableAnalyticsLogging: isAnalyticsEnabled(getState), enableAnalyticsLogging: isAnalyticsEnabled(getState),
...config ...config
}); });
JitsiMeetJS.setNetworkInfo({
isOnline: isOnline(state)
});
dispatch({ type: LIB_DID_INIT }); dispatch({ type: LIB_DID_INIT });
} catch (error) { } catch (error) {
dispatch(libInitError(error)); dispatch(libInitError(error));

View File

@ -2,6 +2,7 @@
import { SET_CONFIG } from '../config'; import { SET_CONFIG } from '../config';
import { setLoggingConfig } from '../logging'; import { setLoggingConfig } from '../logging';
import { SET_NETWORK_INFO } from '../net-info';
import { PARTICIPANT_LEFT } from '../participants'; import { PARTICIPANT_LEFT } from '../participants';
import { MiddlewareRegistry } from '../redux'; import { MiddlewareRegistry } from '../redux';
@ -31,6 +32,12 @@ MiddlewareRegistry.register(store => next => action => {
} }
break; break;
case SET_NETWORK_INFO:
JitsiMeetJS.setNetworkInfo({
isOnline: action.isOnline
});
break;
case PARTICIPANT_LEFT: case PARTICIPANT_LEFT:
action.participant.local && store.dispatch(disposeLib()); action.participant.local && store.dispatch(disposeLib());
break; break;

View File

@ -0,0 +1,11 @@
import { STORE_NAME } from './constants';
/**
* A selector for the internet online status.
*
* @param {Object} state - The redux state.
* @returns {boolean}
*/
export function isOnline(state) {
return state[STORE_NAME].isOnline;
}