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 5.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. // @flow
  2. import Filmstrip from '../../../modules/UI/videolayout/Filmstrip';
  3. import VideoLayout from '../../../modules/UI/videolayout/VideoLayout';
  4. import { StateListenerRegistry, equals } from '../base/redux';
  5. import { getCurrentLayout, getTileViewGridDimensions, shouldDisplayTileView, LAYOUTS } from '../video-layout';
  6. import { setHorizontalViewDimensions, setTileViewDimensions } from './actions.web';
  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. if (!equals(gridDimensions, oldGridDimensions)) {
  18. const { clientHeight, clientWidth } = state['features/base/responsive-ui'];
  19. const { isOpen } = state['features/chat'];
  20. const { visible } = state['features/toolbox'];
  21. store.dispatch(
  22. setTileViewDimensions(
  23. gridDimensions,
  24. {
  25. clientHeight,
  26. clientWidth
  27. },
  28. isOpen,
  29. visible
  30. )
  31. );
  32. }
  33. }
  34. });
  35. /**
  36. * Listens for changes in the selected layout to calculate the dimensions of the tile view grid and horizontal view.
  37. */
  38. StateListenerRegistry.register(
  39. /* selector */ state => getCurrentLayout(state),
  40. /* listener */ (layout, store) => {
  41. const state = store.getState();
  42. switch (layout) {
  43. case LAYOUTS.TILE_VIEW: {
  44. const { clientHeight, clientWidth } = state['features/base/responsive-ui'];
  45. const { isOpen } = state['features/chat'];
  46. const { visible } = state['features/toolbox'];
  47. store.dispatch(
  48. setTileViewDimensions(
  49. getTileViewGridDimensions(state),
  50. {
  51. clientHeight,
  52. clientWidth
  53. },
  54. isOpen,
  55. visible
  56. )
  57. );
  58. break;
  59. }
  60. case LAYOUTS.HORIZONTAL_FILMSTRIP_VIEW:
  61. store.dispatch(setHorizontalViewDimensions(state['features/base/responsive-ui'].clientHeight));
  62. break;
  63. case LAYOUTS.VERTICAL_FILMSTRIP_VIEW:
  64. // Once the thumbnails are reactified this should be moved there too.
  65. Filmstrip.resizeThumbnailsForVerticalView();
  66. break;
  67. }
  68. });
  69. /**
  70. * Handles on stage participant updates.
  71. */
  72. StateListenerRegistry.register(
  73. /* selector */ state => state['features/large-video'].participantId,
  74. /* listener */ (participantId, store, oldParticipantId) => {
  75. const newThumbnail = VideoLayout.getSmallVideo(participantId);
  76. const oldThumbnail = VideoLayout.getSmallVideo(oldParticipantId);
  77. if (newThumbnail) {
  78. newThumbnail.updateView();
  79. }
  80. if (oldThumbnail) {
  81. oldThumbnail.updateView();
  82. }
  83. }
  84. );
  85. /**
  86. * Listens for changes in the chat state to calculate the dimensions of the tile view grid and the tiles.
  87. */
  88. StateListenerRegistry.register(
  89. /* selector */ state => state['features/chat'].isOpen,
  90. /* listener */ (isChatOpen, store) => {
  91. const state = store.getState();
  92. if (isChatOpen) {
  93. // $FlowFixMe
  94. document.body.classList.add('shift-right');
  95. } else {
  96. // $FlowFixMe
  97. document.body.classList.remove('shift-right');
  98. }
  99. if (shouldDisplayTileView(state)) {
  100. const gridDimensions = getTileViewGridDimensions(state);
  101. const { clientHeight, clientWidth } = state['features/base/responsive-ui'];
  102. const { visible } = state['features/toolbox'];
  103. store.dispatch(
  104. setTileViewDimensions(
  105. gridDimensions,
  106. {
  107. clientHeight,
  108. clientWidth
  109. },
  110. isChatOpen,
  111. visible
  112. )
  113. );
  114. }
  115. });
  116. /**
  117. * Listens for changes in the chat state to calculate the dimensions of the tile view grid and the tiles.
  118. */
  119. StateListenerRegistry.register(
  120. /* selector */ state => state['features/toolbox'].visible,
  121. /* listener */ (visible, store) => {
  122. const state = store.getState();
  123. if (shouldDisplayTileView(state)) {
  124. const gridDimensions = getTileViewGridDimensions(state);
  125. const { clientHeight, clientWidth } = state['features/base/responsive-ui'];
  126. const { isOpen } = state['features/chat'];
  127. store.dispatch(
  128. setTileViewDimensions(
  129. gridDimensions,
  130. {
  131. clientHeight,
  132. clientWidth
  133. },
  134. isOpen,
  135. visible
  136. )
  137. );
  138. }
  139. });