2021-08-23 23:02:41 +00:00
|
|
|
// @flow
|
|
|
|
|
|
|
|
import { PARTICIPANT_JOINED, PARTICIPANT_LEFT } from '../base/participants';
|
|
|
|
import { MiddlewareRegistry } from '../base/redux';
|
2022-05-06 10:18:57 +00:00
|
|
|
import { CLIENT_RESIZED, SAFE_AREA_INSETS_CHANGED, SET_ASPECT_RATIO } from '../base/responsive-ui';
|
2021-08-23 23:02:41 +00:00
|
|
|
|
2021-08-20 23:32:38 +00:00
|
|
|
import { setTileViewDimensions } from './actions';
|
2021-08-23 23:02:41 +00:00
|
|
|
import { updateRemoteParticipants, updateRemoteParticipantsOnLeave } from './functions';
|
|
|
|
import './subscriber';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The middleware of the feature Filmstrip.
|
|
|
|
*/
|
|
|
|
MiddlewareRegistry.register(store => next => action => {
|
2021-08-20 23:32:38 +00:00
|
|
|
if (action.type === PARTICIPANT_LEFT) {
|
2021-08-26 23:23:38 +00:00
|
|
|
// This have to be executed before we remove the participant from features/base/participants state in order to
|
|
|
|
// remove the related thumbnail component before we need to re-render it. If we do this after next()
|
|
|
|
// we will be in sitation where the participant exists in the remoteParticipants array in features/filmstrip
|
|
|
|
// but doesn't exist in features/base/participants state which will lead to rendering a thumbnail for
|
|
|
|
// non-existing participant.
|
2021-08-20 23:32:38 +00:00
|
|
|
updateRemoteParticipantsOnLeave(store, action.participant?.id);
|
|
|
|
}
|
|
|
|
|
2021-08-23 23:02:41 +00:00
|
|
|
const result = next(action);
|
|
|
|
|
|
|
|
switch (action.type) {
|
2021-08-20 23:32:38 +00:00
|
|
|
case CLIENT_RESIZED:
|
2022-05-06 10:18:57 +00:00
|
|
|
case SAFE_AREA_INSETS_CHANGED:
|
2021-08-20 23:32:38 +00:00
|
|
|
case SET_ASPECT_RATIO:
|
|
|
|
store.dispatch(setTileViewDimensions());
|
|
|
|
break;
|
2021-08-23 23:02:41 +00:00
|
|
|
case PARTICIPANT_JOINED: {
|
2021-09-15 15:59:06 +00:00
|
|
|
updateRemoteParticipants(store, action.participant?.id);
|
2021-08-23 23:02:41 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
|
|
});
|