2020-04-16 10:47:10 +00:00
|
|
|
// @flow
|
|
|
|
|
2020-08-14 07:45:15 +00:00
|
|
|
import { updateConfig } from '../base/config';
|
2020-06-29 07:45:28 +00:00
|
|
|
import { SET_AUDIO_MUTED, SET_VIDEO_MUTED } from '../base/media';
|
2020-05-20 10:57:03 +00:00
|
|
|
import { MiddlewareRegistry } from '../base/redux';
|
|
|
|
import { updateSettings } from '../base/settings';
|
2020-08-12 07:19:31 +00:00
|
|
|
import {
|
|
|
|
getLocalVideoTrack,
|
|
|
|
replaceLocalTrack,
|
|
|
|
TRACK_ADDED,
|
|
|
|
TRACK_NO_DATA_FROM_SOURCE
|
|
|
|
} from '../base/tracks';
|
2020-05-20 10:57:03 +00:00
|
|
|
|
2020-06-19 07:03:26 +00:00
|
|
|
import { PREJOIN_START_CONFERENCE } from './actionTypes';
|
2020-08-12 07:19:31 +00:00
|
|
|
import {
|
|
|
|
setDeviceStatusOk,
|
|
|
|
setDeviceStatusWarning,
|
|
|
|
setPrejoinPageVisibility
|
|
|
|
} from './actions';
|
2020-06-29 07:45:28 +00:00
|
|
|
import { isPrejoinPageVisible } from './functions';
|
2020-04-16 10:47:10 +00:00
|
|
|
|
|
|
|
declare var APP: Object;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The redux middleware for {@link PrejoinPage}.
|
|
|
|
*
|
|
|
|
* @param {Store} store - The redux store.
|
|
|
|
* @returns {Function}
|
|
|
|
*/
|
|
|
|
MiddlewareRegistry.register(store => next => async action => {
|
|
|
|
switch (action.type) {
|
|
|
|
case PREJOIN_START_CONFERENCE: {
|
2020-05-07 07:42:55 +00:00
|
|
|
const { getState, dispatch } = store;
|
|
|
|
const state = getState();
|
|
|
|
const { userSelectedSkipPrejoin } = state['features/prejoin'];
|
2020-07-08 09:59:46 +00:00
|
|
|
const localVideoTrack = getLocalVideoTrack(state['features/base/tracks']);
|
2020-08-14 07:45:15 +00:00
|
|
|
const { options } = action;
|
|
|
|
|
|
|
|
options && store.dispatch(updateConfig(options));
|
2020-05-07 07:42:55 +00:00
|
|
|
|
|
|
|
userSelectedSkipPrejoin && dispatch(updateSettings({
|
|
|
|
userSelectedSkipPrejoin
|
|
|
|
}));
|
2020-04-16 10:47:10 +00:00
|
|
|
|
2020-07-08 09:59:46 +00:00
|
|
|
if (localVideoTrack?.muted) {
|
|
|
|
await dispatch(replaceLocalTrack(localVideoTrack.jitsiTrack, null));
|
|
|
|
}
|
|
|
|
|
|
|
|
const jitsiTracks = getState()['features/base/tracks'].map(t => t.jitsiTrack);
|
|
|
|
|
|
|
|
dispatch(setPrejoinPageVisibility(false));
|
|
|
|
APP.conference.prejoinStart(jitsiTracks);
|
2020-04-16 10:47:10 +00:00
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
2020-06-29 07:45:28 +00:00
|
|
|
|
|
|
|
case SET_AUDIO_MUTED: {
|
|
|
|
if (isPrejoinPageVisible(store.getState())) {
|
|
|
|
store.dispatch(updateSettings({
|
|
|
|
startWithAudioMuted: Boolean(action.muted)
|
|
|
|
}));
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case SET_VIDEO_MUTED: {
|
|
|
|
if (isPrejoinPageVisible(store.getState())) {
|
|
|
|
store.dispatch(updateSettings({
|
|
|
|
startWithVideoMuted: Boolean(action.muted)
|
|
|
|
}));
|
|
|
|
}
|
|
|
|
break;
|
2020-04-16 10:47:10 +00:00
|
|
|
}
|
|
|
|
|
2020-08-12 07:19:31 +00:00
|
|
|
case TRACK_ADDED:
|
|
|
|
case TRACK_NO_DATA_FROM_SOURCE: {
|
|
|
|
const state = store.getState();
|
|
|
|
|
|
|
|
if (isPrejoinPageVisible(state)) {
|
|
|
|
const { track: { jitsiTrack: track } } = action;
|
|
|
|
const { deviceStatusType, deviceStatusText } = state['features/prejoin'];
|
|
|
|
|
|
|
|
if (!track.isAudioTrack()) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (track.isReceivingData()) {
|
|
|
|
if (deviceStatusType === 'warning'
|
|
|
|
&& deviceStatusText === 'prejoin.audioDeviceProblem') {
|
|
|
|
store.dispatch(setDeviceStatusOk('prejoin.lookGood'));
|
|
|
|
}
|
|
|
|
} else if (deviceStatusType === 'ok') {
|
|
|
|
store.dispatch(setDeviceStatusWarning('prejoin.audioDeviceProblem'));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2020-06-29 07:45:28 +00:00
|
|
|
}
|
2020-04-16 10:47:10 +00:00
|
|
|
|
|
|
|
return next(action);
|
|
|
|
});
|