您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

subscriber.web.js 4.2KB

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