2018-05-18 12:59:07 -07:00
|
|
|
// @flow
|
|
|
|
|
|
2018-05-17 17:41:28 -07:00
|
|
|
import VideoLayout from '../../../modules/UI/videolayout/VideoLayout.js';
|
2020-11-09 14:59:13 -06:00
|
|
|
import { CONFERENCE_WILL_LEAVE } from '../base/conference';
|
2021-01-06 17:45:48 -06:00
|
|
|
import { MEDIA_TYPE } from '../base/media';
|
2018-05-18 12:59:07 -07:00
|
|
|
import {
|
2021-01-21 14:46:47 -06:00
|
|
|
getLocalParticipant,
|
2018-05-22 10:13:51 -07:00
|
|
|
PARTICIPANT_JOINED,
|
2021-01-21 14:46:47 -06:00
|
|
|
PARTICIPANT_UPDATED
|
2018-05-18 12:59:07 -07:00
|
|
|
} from '../base/participants';
|
2018-05-17 15:42:21 -07:00
|
|
|
import { MiddlewareRegistry } from '../base/redux';
|
2021-01-21 14:46:47 -06:00
|
|
|
import { TRACK_ADDED, TRACK_REMOVED, TRACK_STOPPED } from '../base/tracks';
|
2018-09-10 15:10:45 -07:00
|
|
|
import { SET_FILMSTRIP_VISIBLE } from '../filmstrip';
|
2021-05-07 10:02:50 +03:00
|
|
|
import { PARTICIPANTS_PANE_CLOSE, PARTICIPANTS_PANE_OPEN } from '../participants-pane/actionTypes.js';
|
2018-05-17 15:42:21 -07:00
|
|
|
|
2018-11-28 11:36:23 -08:00
|
|
|
import './middleware.any';
|
2018-08-08 11:48:23 -07:00
|
|
|
|
2018-05-18 12:59:07 -07:00
|
|
|
declare var APP: Object;
|
|
|
|
|
|
2018-05-17 15:42:21 -07: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-17 17:41:28 -07:00
|
|
|
MiddlewareRegistry.register(store => next => action => {
|
2018-05-18 12:59:07 -07:00
|
|
|
// Purposefully perform additional actions after state update to mimic
|
|
|
|
|
// being connected to the store for updates.
|
2018-05-17 17:41:28 -07:00
|
|
|
const result = next(action);
|
|
|
|
|
|
|
|
|
|
switch (action.type) {
|
2019-01-01 13:19:34 -08:00
|
|
|
case CONFERENCE_WILL_LEAVE:
|
|
|
|
|
VideoLayout.reset();
|
|
|
|
|
break;
|
|
|
|
|
|
2018-05-22 10:13:51 -07:00
|
|
|
case PARTICIPANT_JOINED:
|
|
|
|
|
if (!action.participant.local) {
|
2021-01-21 14:46:47 -06:00
|
|
|
VideoLayout.updateVideoMutedForNoTracks(action.participant.id);
|
2018-05-22 10:13:51 -07:00
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
2018-05-21 14:06:02 -07: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 10:44:12 -07:00
|
|
|
action.participant.id,
|
|
|
|
|
action.participant.connectionStatus);
|
2018-05-21 14:06:02 -07:00
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2021-05-07 10:02:50 +03:00
|
|
|
case PARTICIPANTS_PANE_CLOSE:
|
|
|
|
|
case PARTICIPANTS_PANE_OPEN:
|
2018-09-10 15:10:45 -07:00
|
|
|
case SET_FILMSTRIP_VISIBLE:
|
2020-02-10 15:27:43 +00:00
|
|
|
VideoLayout.resizeVideoArea();
|
2018-09-10 15:10:45 -07:00
|
|
|
break;
|
|
|
|
|
|
2018-06-21 21:33:33 -07:00
|
|
|
case TRACK_ADDED:
|
2021-01-21 14:46:47 -06:00
|
|
|
if (action.track.mediaType !== MEDIA_TYPE.AUDIO) {
|
|
|
|
|
VideoLayout._updateLargeVideoIfDisplayed(action.track.participantId, true);
|
2018-06-21 21:33:33 -07:00
|
|
|
}
|
|
|
|
|
|
2019-05-28 13:28:33 -07:00
|
|
|
break;
|
2021-01-21 14:46:47 -06:00
|
|
|
|
|
|
|
|
case TRACK_STOPPED: {
|
|
|
|
|
if (action.track.jitsiTrack.isLocal()) {
|
|
|
|
|
const participant = getLocalParticipant(store.getState);
|
|
|
|
|
|
|
|
|
|
VideoLayout._updateLargeVideoIfDisplayed(participant?.id);
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
2019-05-28 13:28:33 -07:00
|
|
|
case TRACK_REMOVED:
|
2020-11-09 14:59:13 -06:00
|
|
|
if (!action.track.local && action.track.mediaType !== MEDIA_TYPE.AUDIO) {
|
2021-01-21 14:46:47 -06:00
|
|
|
VideoLayout.updateVideoMutedForNoTracks(action.track.jitsiTrack.getParticipantId());
|
2019-05-28 13:28:33 -07:00
|
|
|
}
|
|
|
|
|
|
2018-06-21 21:33:33 -07:00
|
|
|
break;
|
2018-05-17 17:41:28 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
});
|