2022-10-27 07:33:11 +00:00
|
|
|
// @ts-expect-error
|
2018-05-18 00:41:28 +00:00
|
|
|
import VideoLayout from '../../../modules/UI/videolayout/VideoLayout.js';
|
2022-10-27 07:33:11 +00:00
|
|
|
import { CONFERENCE_WILL_LEAVE } from '../base/conference/actionTypes';
|
|
|
|
import { MEDIA_TYPE } from '../base/media/constants';
|
2022-11-08 19:15:49 +00:00
|
|
|
import { PARTICIPANT_JOINED } from '../base/participants/actionTypes';
|
2022-10-27 07:33:11 +00:00
|
|
|
import { getLocalParticipant } from '../base/participants/functions';
|
|
|
|
import MiddlewareRegistry from '../base/redux/MiddlewareRegistry';
|
|
|
|
import { TRACK_ADDED, TRACK_REMOVED, TRACK_STOPPED } from '../base/tracks/actionTypes';
|
2022-04-08 12:24:58 +00:00
|
|
|
import { PARTICIPANTS_PANE_CLOSE, PARTICIPANTS_PANE_OPEN } from '../participants-pane/actionTypes';
|
2018-05-17 22:42:21 +00:00
|
|
|
|
2018-11-28 19:36:23 +00:00
|
|
|
import './middleware.any';
|
2018-08-08 18:48:23 +00:00
|
|
|
|
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) {
|
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) {
|
2021-01-21 20:46:47 +00:00
|
|
|
VideoLayout.updateVideoMutedForNoTracks(action.participant.id);
|
2018-05-22 17:13:51 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2021-05-07 07:02:50 +00:00
|
|
|
case PARTICIPANTS_PANE_CLOSE:
|
|
|
|
case PARTICIPANTS_PANE_OPEN:
|
2020-02-10 15:27:43 +00:00
|
|
|
VideoLayout.resizeVideoArea();
|
2018-09-10 22:10:45 +00:00
|
|
|
break;
|
|
|
|
|
2018-06-22 04:33:33 +00:00
|
|
|
case TRACK_ADDED:
|
2021-01-21 20:46:47 +00:00
|
|
|
if (action.track.mediaType !== MEDIA_TYPE.AUDIO) {
|
|
|
|
VideoLayout._updateLargeVideoIfDisplayed(action.track.participantId, true);
|
2018-06-22 04:33:33 +00:00
|
|
|
}
|
|
|
|
|
2019-05-28 20:28:33 +00:00
|
|
|
break;
|
2021-01-21 20:46:47 +00:00
|
|
|
|
|
|
|
case TRACK_STOPPED: {
|
|
|
|
if (action.track.jitsiTrack.isLocal()) {
|
|
|
|
const participant = getLocalParticipant(store.getState);
|
|
|
|
|
|
|
|
VideoLayout._updateLargeVideoIfDisplayed(participant?.id);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2019-05-28 20:28:33 +00:00
|
|
|
case TRACK_REMOVED:
|
2020-11-09 20:59:13 +00:00
|
|
|
if (!action.track.local && action.track.mediaType !== MEDIA_TYPE.AUDIO) {
|
2021-01-21 20:46:47 +00:00
|
|
|
VideoLayout.updateVideoMutedForNoTracks(action.track.jitsiTrack.getParticipantId());
|
2019-05-28 20:28:33 +00:00
|
|
|
}
|
|
|
|
|
2018-06-22 04:33:33 +00:00
|
|
|
break;
|
2018-05-18 00:41:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
|
|
});
|