2018-05-18 19:59:07 +00:00
|
|
|
// @flow
|
|
|
|
|
2018-05-18 00:41:28 +00:00
|
|
|
import VideoLayout from '../../../modules/UI/videolayout/VideoLayout.js';
|
2018-05-18 19:59:07 +00:00
|
|
|
import UIEvents from '../../../service/UI/UIEvents';
|
2018-05-18 00:41:28 +00:00
|
|
|
|
2019-01-01 21:19:34 +00:00
|
|
|
import { CONFERENCE_JOINED, CONFERENCE_WILL_LEAVE } from '../base/conference';
|
2018-05-18 19:59:07 +00:00
|
|
|
import {
|
|
|
|
DOMINANT_SPEAKER_CHANGED,
|
2018-05-22 17:13:51 +00:00
|
|
|
PARTICIPANT_JOINED,
|
2018-05-21 21:22:41 +00:00
|
|
|
PARTICIPANT_LEFT,
|
2018-05-21 21:06:02 +00:00
|
|
|
PARTICIPANT_UPDATED,
|
2018-05-22 17:13:51 +00:00
|
|
|
PIN_PARTICIPANT,
|
|
|
|
getParticipantById
|
2018-05-18 19:59:07 +00:00
|
|
|
} from '../base/participants';
|
2018-05-17 22:42:21 +00:00
|
|
|
import { MiddlewareRegistry } from '../base/redux';
|
2018-06-22 04:33:33 +00:00
|
|
|
import { TRACK_ADDED } from '../base/tracks';
|
2018-09-10 22:10:45 +00:00
|
|
|
import { SET_FILMSTRIP_VISIBLE } from '../filmstrip';
|
2018-05-17 22:42:21 +00:00
|
|
|
|
2018-08-08 18:48:23 +00:00
|
|
|
import { SET_TILE_VIEW } from './actionTypes';
|
2018-11-28 19:36:23 +00:00
|
|
|
import './middleware.any';
|
2018-08-08 18:48:23 +00:00
|
|
|
|
2018-05-18 19:59:07 +00:00
|
|
|
declare var APP: Object;
|
|
|
|
|
2018-05-17 22:42:21 +00:00
|
|
|
/**
|
|
|
|
* Middleware which intercepts actions and updates the legacy component
|
|
|
|
* {@code VideoLayout} as needed. The purpose of this middleware is to redux-ify
|
|
|
|
* {@code VideoLayout} without having to simultaneously react-ifying it.
|
|
|
|
*
|
|
|
|
* @param {Store} store - The redux store.
|
|
|
|
* @returns {Function}
|
|
|
|
*/
|
|
|
|
// eslint-disable-next-line no-unused-vars
|
2018-05-18 00:41:28 +00:00
|
|
|
MiddlewareRegistry.register(store => next => action => {
|
2018-05-18 19:59:07 +00:00
|
|
|
// Purposefully perform additional actions after state update to mimic
|
|
|
|
// being connected to the store for updates.
|
2018-05-18 00:41:28 +00:00
|
|
|
const result = next(action);
|
|
|
|
|
|
|
|
switch (action.type) {
|
2018-06-22 04:33:33 +00:00
|
|
|
case CONFERENCE_JOINED:
|
|
|
|
VideoLayout.mucJoined();
|
|
|
|
break;
|
|
|
|
|
2019-01-01 21:19:34 +00:00
|
|
|
case CONFERENCE_WILL_LEAVE:
|
|
|
|
VideoLayout.reset();
|
|
|
|
break;
|
|
|
|
|
2018-05-22 17:13:51 +00:00
|
|
|
case PARTICIPANT_JOINED:
|
|
|
|
if (!action.participant.local) {
|
|
|
|
VideoLayout.addRemoteParticipantContainer(
|
|
|
|
getParticipantById(store.getState(), action.participant.id));
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2018-05-21 21:22:41 +00:00
|
|
|
case PARTICIPANT_LEFT:
|
|
|
|
VideoLayout.removeParticipantContainer(action.participant.id);
|
|
|
|
break;
|
2018-05-21 21:06:02 +00:00
|
|
|
|
|
|
|
case PARTICIPANT_UPDATED: {
|
|
|
|
// Look for actions that triggered a change to connectionStatus. This is
|
|
|
|
// done instead of changing the connection status change action to be
|
|
|
|
// explicit in order to minimize changes to other code.
|
|
|
|
if (typeof action.participant.connectionStatus !== 'undefined') {
|
|
|
|
VideoLayout.onParticipantConnectionStatusChanged(
|
2018-06-25 17:44:12 +00:00
|
|
|
action.participant.id,
|
|
|
|
action.participant.connectionStatus);
|
2018-05-21 21:06:02 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2018-05-18 00:41:28 +00:00
|
|
|
case DOMINANT_SPEAKER_CHANGED:
|
|
|
|
VideoLayout.onDominantSpeakerChanged(action.participant.id);
|
|
|
|
break;
|
2018-05-18 19:59:07 +00:00
|
|
|
|
|
|
|
case PIN_PARTICIPANT:
|
|
|
|
VideoLayout.onPinChange(action.participant.id);
|
|
|
|
APP.UI.emitEvent(
|
|
|
|
UIEvents.PINNED_ENDPOINT,
|
|
|
|
action.participant.id,
|
|
|
|
Boolean(action.participant.id));
|
|
|
|
break;
|
2018-06-22 04:33:33 +00:00
|
|
|
|
2018-09-10 22:10:45 +00:00
|
|
|
case SET_FILMSTRIP_VISIBLE:
|
|
|
|
VideoLayout.resizeVideoArea(true, false);
|
|
|
|
APP.UI.emitEvent(UIEvents.TOGGLED_FILMSTRIP, action.visible);
|
2019-03-11 18:17:28 +00:00
|
|
|
APP.API.notifyFilmstripDisplayChanged(action.visible);
|
2018-09-10 22:10:45 +00:00
|
|
|
break;
|
|
|
|
|
2018-08-08 18:48:23 +00:00
|
|
|
case SET_TILE_VIEW:
|
|
|
|
APP.UI.emitEvent(UIEvents.TOGGLED_TILE_VIEW, action.enabled);
|
|
|
|
break;
|
|
|
|
|
2018-06-22 04:33:33 +00:00
|
|
|
case TRACK_ADDED:
|
|
|
|
if (!action.track.local) {
|
|
|
|
VideoLayout.onRemoteStreamAdded(action.track.jitsiTrack);
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
2018-05-18 00:41:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
|
|
});
|