2020-11-04 08:32:06 +00:00
|
|
|
// @flow
|
|
|
|
|
|
|
|
import UIEvents from '../../../../service/UI/UIEvents';
|
2021-02-04 17:33:18 +00:00
|
|
|
import { setPrejoinPageVisibility, setSkipPrejoinOnReload } from '../../prejoin';
|
|
|
|
import { JitsiConferenceErrors } from '../lib-jitsi-meet';
|
2020-11-04 08:32:06 +00:00
|
|
|
import { MiddlewareRegistry } from '../redux';
|
|
|
|
import { TOGGLE_SCREENSHARING } from '../tracks/actionTypes';
|
|
|
|
|
2021-02-04 17:33:18 +00:00
|
|
|
import { CONFERENCE_FAILED, CONFERENCE_JOINED } from './actionTypes';
|
2020-11-04 08:32:06 +00:00
|
|
|
import './middleware.any';
|
|
|
|
|
|
|
|
declare var APP: Object;
|
|
|
|
|
2021-02-04 17:33:18 +00:00
|
|
|
MiddlewareRegistry.register(({ dispatch, getState }) => next => action => {
|
|
|
|
const { enableForcedReload } = getState()['features/base/config'];
|
|
|
|
|
2020-11-04 08:32:06 +00:00
|
|
|
switch (action.type) {
|
2021-02-04 17:33:18 +00:00
|
|
|
case CONFERENCE_JOINED: {
|
|
|
|
if (enableForcedReload) {
|
|
|
|
dispatch(setPrejoinPageVisibility(false));
|
|
|
|
dispatch(setSkipPrejoinOnReload(false));
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case CONFERENCE_FAILED: {
|
|
|
|
enableForcedReload
|
|
|
|
&& action.error?.name === JitsiConferenceErrors.CONFERENCE_RESTARTED
|
|
|
|
&& dispatch(setSkipPrejoinOnReload(true));
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
2020-11-04 08:32:06 +00:00
|
|
|
case TOGGLE_SCREENSHARING: {
|
|
|
|
if (typeof APP === 'object') {
|
2021-04-12 07:37:39 +00:00
|
|
|
APP.UI.emitEvent(UIEvents.TOGGLE_SCREENSHARING, action.audioOnly);
|
2020-11-04 08:32:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return next(action);
|
|
|
|
});
|