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.

subscriber.web.js 2.3KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. // @flow
  2. import { StateListenerRegistry, equals } from '../base/redux';
  3. import Filmstrip from '../../../modules/UI/videolayout/Filmstrip';
  4. import { getCurrentLayout, getTileViewGridDimensions, shouldDisplayTileView, LAYOUTS } from '../video-layout';
  5. import { setHorizontalViewDimensions, setTileViewDimensions } from './actions';
  6. /**
  7. * Listens for changes in the number of participants to calculate the dimensions of the tile view grid and the tiles.
  8. */
  9. StateListenerRegistry.register(
  10. /* selector */ state => state['features/base/participants'].length,
  11. /* listener */ (numberOfParticipants, store) => {
  12. const state = store.getState();
  13. if (shouldDisplayTileView(state)) {
  14. const gridDimensions = getTileViewGridDimensions(state['features/base/participants'].length);
  15. const oldGridDimensions = state['features/filmstrip'].tileViewDimensions.gridDimensions;
  16. const { clientHeight, clientWidth } = state['features/base/responsive-ui'];
  17. if (!equals(gridDimensions, oldGridDimensions)) {
  18. store.dispatch(setTileViewDimensions(gridDimensions, {
  19. clientHeight,
  20. clientWidth
  21. }));
  22. }
  23. }
  24. });
  25. /**
  26. * Listens for changes in the selected layout to calculate the dimensions of the tile view grid and horizontal view.
  27. */
  28. StateListenerRegistry.register(
  29. /* selector */ state => getCurrentLayout(state),
  30. /* listener */ (layout, store) => {
  31. const state = store.getState();
  32. switch (layout) {
  33. case LAYOUTS.TILE_VIEW: {
  34. const { clientHeight, clientWidth } = state['features/base/responsive-ui'];
  35. store.dispatch(setTileViewDimensions(
  36. getTileViewGridDimensions(state['features/base/participants'].length), {
  37. clientHeight,
  38. clientWidth
  39. }));
  40. break;
  41. }
  42. case LAYOUTS.HORIZONTAL_FILMSTRIP_VIEW:
  43. store.dispatch(setHorizontalViewDimensions(state['features/base/responsive-ui'].clientHeight));
  44. break;
  45. case LAYOUTS.VERTICAL_FILMSTRIP_VIEW:
  46. // Once the thumbnails are reactified this should be moved there too.
  47. Filmstrip.resizeThumbnailsForVerticalView();
  48. break;
  49. }
  50. });