2022-11-10 08:45:56 +00:00
|
|
|
import { PARTICIPANT_JOINED, PARTICIPANT_LEFT } from '../base/participants/actionTypes';
|
|
|
|
import MiddlewareRegistry from '../base/redux/MiddlewareRegistry';
|
|
|
|
import { CLIENT_RESIZED, SAFE_AREA_INSETS_CHANGED, SET_ASPECT_RATIO } from '../base/responsive-ui/actionTypes';
|
2021-08-23 23:02:41 +00:00
|
|
|
|
2022-11-10 08:45:56 +00:00
|
|
|
import { setTileViewDimensions } from './actions.native';
|
|
|
|
import { updateRemoteParticipants, updateRemoteParticipantsOnLeave } from './functions.native';
|
|
|
|
import './subscriber.native';
|
2021-08-23 23:02:41 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* 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()
|
2022-07-14 07:10:08 +00:00
|
|
|
// we will be in situation where the participant exists in the remoteParticipants array in features/filmstrip
|
2021-08-26 23:23:38 +00:00
|
|
|
// 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;
|
|
|
|
});
|