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.8KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. // @flow
  2. import { StateListenerRegistry, equals } from '../base/redux';
  3. import Filmstrip from '../../../modules/UI/videolayout/Filmstrip';
  4. import VideoLayout from '../../../modules/UI/videolayout/VideoLayout';
  5. import { getCurrentLayout, getTileViewGridDimensions, shouldDisplayTileView, LAYOUTS } from '../video-layout';
  6. import { setHorizontalViewDimensions, setTileViewDimensions } from './actions';
  7. /**
  8. * Listens for changes in the number of participants to calculate the dimensions of the tile view grid and the tiles.
  9. */
  10. StateListenerRegistry.register(
  11. /* selector */ state => state['features/base/participants'].length,
  12. /* listener */ (numberOfParticipants, store) => {
  13. const state = store.getState();
  14. if (shouldDisplayTileView(state)) {
  15. const gridDimensions = getTileViewGridDimensions(state);
  16. const oldGridDimensions = state['features/filmstrip'].tileViewDimensions.gridDimensions;
  17. const { clientHeight, clientWidth } = state['features/base/responsive-ui'];
  18. if (!equals(gridDimensions, oldGridDimensions)) {
  19. store.dispatch(setTileViewDimensions(gridDimensions, {
  20. clientHeight,
  21. clientWidth
  22. }));
  23. }
  24. }
  25. });
  26. /**
  27. * Listens for changes in the selected layout to calculate the dimensions of the tile view grid and horizontal view.
  28. */
  29. StateListenerRegistry.register(
  30. /* selector */ state => getCurrentLayout(state),
  31. /* listener */ (layout, store) => {
  32. const state = store.getState();
  33. clog("SWJ",layout, store,state)
  34. switch (layout) {
  35. case LAYOUTS.TILE_VIEW: {
  36. const { clientHeight, clientWidth } = state['features/base/responsive-ui'];
  37. store.dispatch(setTileViewDimensions(
  38. getTileViewGridDimensions(state), {
  39. clientHeight,
  40. clientWidth
  41. }));
  42. break;
  43. }
  44. case LAYOUTS.HORIZONTAL_FILMSTRIP_VIEW:
  45. store.dispatch(setHorizontalViewDimensions(state['features/base/responsive-ui'].clientHeight));
  46. break;
  47. case LAYOUTS.VERTICAL_FILMSTRIP_VIEW:
  48. // Once the thumbnails are reactified this should be moved there too.
  49. Filmstrip.resizeThumbnailsForVerticalView();
  50. break;
  51. }
  52. });
  53. /**
  54. * Handles on stage participant updates.
  55. */
  56. StateListenerRegistry.register(
  57. /* selector */ state => state['features/large-video'].participantId,
  58. /* listener */ (participantId, store, oldParticipantId) => {
  59. const newThumbnail = VideoLayout.getSmallVideo(participantId);
  60. const oldThumbnail = VideoLayout.getSmallVideo(oldParticipantId);
  61. if (newThumbnail) {
  62. newThumbnail.updateView();
  63. }
  64. if (oldThumbnail) {
  65. oldThumbnail.updateView();
  66. }
  67. }
  68. );