You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

middleware.native.js 1.4KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. // @flow
  2. import { PARTICIPANT_JOINED, PARTICIPANT_LEFT } from '../base/participants';
  3. import { MiddlewareRegistry } from '../base/redux';
  4. import { CLIENT_RESIZED, SET_ASPECT_RATIO } from '../base/responsive-ui';
  5. import { setTileViewDimensions } from './actions';
  6. import { updateRemoteParticipants, updateRemoteParticipantsOnLeave } from './functions';
  7. import './subscriber';
  8. /**
  9. * The middleware of the feature Filmstrip.
  10. */
  11. MiddlewareRegistry.register(store => next => action => {
  12. if (action.type === PARTICIPANT_LEFT) {
  13. // This have to be executed before we remove the participant from features/base/participants state in order to
  14. // remove the related thumbnail component before we need to re-render it. If we do this after next()
  15. // we will be in sitation where the participant exists in the remoteParticipants array in features/filmstrip
  16. // but doesn't exist in features/base/participants state which will lead to rendering a thumbnail for
  17. // non-existing participant.
  18. updateRemoteParticipantsOnLeave(store, action.participant?.id);
  19. }
  20. const result = next(action);
  21. switch (action.type) {
  22. case CLIENT_RESIZED:
  23. case SET_ASPECT_RATIO:
  24. store.dispatch(setTileViewDimensions());
  25. break;
  26. case PARTICIPANT_JOINED: {
  27. updateRemoteParticipants(store);
  28. break;
  29. }
  30. }
  31. return result;
  32. });