2020-06-04 14:09:13 +00:00
|
|
|
import { appNavigate } from '../app/actions';
|
2022-11-10 08:45:56 +00:00
|
|
|
import { IStore } from '../app/types';
|
|
|
|
import { CONFERENCE_JOINED, KICKED_OUT } from '../base/conference/actionTypes';
|
|
|
|
import { conferenceLeft } from '../base/conference/actions';
|
|
|
|
import { getCurrentConference } from '../base/conference/functions';
|
|
|
|
import { hideDialog } from '../base/dialog/actions';
|
|
|
|
import { isDialogOpen } from '../base/dialog/functions';
|
|
|
|
import { pinParticipant } from '../base/participants/actions';
|
|
|
|
import MiddlewareRegistry from '../base/redux/MiddlewareRegistry';
|
|
|
|
import StateListenerRegistry from '../base/redux/StateListenerRegistry';
|
|
|
|
import { SET_REDUCED_UI } from '../base/responsive-ui/actionTypes';
|
|
|
|
// eslint-disable-next-line lines-around-comment
|
|
|
|
// @ts-ignore
|
2019-01-15 11:41:03 +00:00
|
|
|
import { FeedbackDialog } from '../feedback';
|
2022-11-10 08:45:56 +00:00
|
|
|
import { setFilmstripEnabled } from '../filmstrip/actions';
|
2022-03-31 13:11:44 +00:00
|
|
|
import { showSalesforceNotification } from '../salesforce/actions';
|
2020-07-24 12:14:33 +00:00
|
|
|
import { setToolboxEnabled } from '../toolbox/actions';
|
2018-02-02 13:41:30 +00:00
|
|
|
|
2020-05-20 10:57:03 +00:00
|
|
|
import { notifyKickedOut } from './actions';
|
|
|
|
|
2018-02-13 19:14:06 +00:00
|
|
|
MiddlewareRegistry.register(store => next => action => {
|
2018-02-02 13:41:30 +00:00
|
|
|
const result = next(action);
|
|
|
|
|
|
|
|
switch (action.type) {
|
|
|
|
case CONFERENCE_JOINED:
|
2022-03-31 13:11:44 +00:00
|
|
|
_conferenceJoined(store);
|
|
|
|
|
|
|
|
break;
|
2018-02-02 13:41:30 +00:00
|
|
|
|
2022-03-31 13:11:44 +00:00
|
|
|
case SET_REDUCED_UI: {
|
|
|
|
_setReducedUI(store);
|
2018-02-02 13:41:30 +00:00
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
2018-03-20 18:07:51 +00:00
|
|
|
|
|
|
|
case KICKED_OUT: {
|
|
|
|
const { dispatch } = store;
|
|
|
|
|
2019-06-17 14:00:09 +00:00
|
|
|
dispatch(notifyKickedOut(
|
|
|
|
action.participant,
|
|
|
|
() => {
|
2019-06-25 07:37:39 +00:00
|
|
|
dispatch(conferenceLeft(action.conference));
|
2019-06-17 14:00:09 +00:00
|
|
|
dispatch(appNavigate(undefined));
|
|
|
|
}
|
|
|
|
));
|
|
|
|
|
2018-03-20 18:07:51 +00:00
|
|
|
break;
|
|
|
|
}
|
2018-02-02 13:41:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
|
|
});
|
2019-01-15 11:41:03 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Set up state change listener to perform maintenance tasks when the conference
|
|
|
|
* is left or failed, close all dialogs and unpin any pinned participants.
|
|
|
|
*/
|
|
|
|
StateListenerRegistry.register(
|
|
|
|
state => getCurrentConference(state),
|
|
|
|
(conference, { dispatch, getState }, prevConference) => {
|
2020-04-15 13:13:43 +00:00
|
|
|
const { authRequired, membersOnly, passwordRequired }
|
2019-01-15 11:41:03 +00:00
|
|
|
= getState()['features/base/conference'];
|
|
|
|
|
|
|
|
if (conference !== prevConference) {
|
|
|
|
// Unpin participant, in order to avoid the local participant
|
|
|
|
// remaining pinned, since it's not destroyed across runs.
|
|
|
|
dispatch(pinParticipant(null));
|
|
|
|
|
|
|
|
// XXX I wonder if there is a better way to do this. At this stage
|
|
|
|
// we do know what dialogs we want to keep but the list of those
|
|
|
|
// we want to hide is a lot longer. Thus we take a bit of a shortcut
|
|
|
|
// and explicitly check.
|
|
|
|
if (typeof authRequired === 'undefined'
|
|
|
|
&& typeof passwordRequired === 'undefined'
|
2020-04-15 13:13:43 +00:00
|
|
|
&& typeof membersOnly === 'undefined'
|
2019-01-15 11:41:03 +00:00
|
|
|
&& !isDialogOpen(getState(), FeedbackDialog)) {
|
|
|
|
// Conference changed, left or failed... and there is no
|
|
|
|
// pending authentication, nor feedback request, so close any
|
|
|
|
// dialog we might have open.
|
|
|
|
dispatch(hideDialog());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
2022-03-31 13:11:44 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Configures the UI. In reduced UI mode some components will
|
|
|
|
* be hidden if there is no space to render them.
|
|
|
|
*
|
|
|
|
* @param {Store} store - The redux store in which the specified {@code action}
|
|
|
|
* is being dispatched.
|
|
|
|
* @private
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
2022-11-10 08:45:56 +00:00
|
|
|
function _setReducedUI({ dispatch, getState }: IStore) {
|
2022-03-31 13:11:44 +00:00
|
|
|
const { reducedUI } = getState()['features/base/responsive-ui'];
|
|
|
|
|
|
|
|
dispatch(setToolboxEnabled(!reducedUI));
|
|
|
|
dispatch(setFilmstripEnabled(!reducedUI));
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Does extra sync up on properties that may need to be updated after the
|
|
|
|
* conference was joined.
|
|
|
|
*
|
|
|
|
* @param {Store} store - The redux store in which the specified {@code action}
|
|
|
|
* is being dispatched.
|
|
|
|
* @private
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
2022-11-10 08:45:56 +00:00
|
|
|
function _conferenceJoined({ dispatch, getState }: IStore) {
|
2022-03-31 13:11:44 +00:00
|
|
|
_setReducedUI({
|
|
|
|
dispatch,
|
|
|
|
getState
|
|
|
|
});
|
|
|
|
|
|
|
|
dispatch(showSalesforceNotification());
|
|
|
|
}
|