Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

subscriber.web.js 5.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. // @flow
  2. import { getParticipantCountWithFake } from '../base/participants';
  3. import { StateListenerRegistry, equals } from '../base/redux';
  4. import { clientResized } from '../base/responsive-ui';
  5. import { setFilmstripVisible } from '../filmstrip/actions';
  6. import { getParticipantsPaneOpen } from '../participants-pane/functions';
  7. import { setOverflowDrawer } from '../toolbox/actions.web';
  8. import { getCurrentLayout, getTileViewGridDimensions, shouldDisplayTileView, LAYOUTS } from '../video-layout';
  9. import { setHorizontalViewDimensions, setTileViewDimensions, setVerticalViewDimensions } from './actions.web';
  10. import {
  11. ASPECT_RATIO_BREAKPOINT,
  12. DISPLAY_DRAWER_THRESHOLD,
  13. SINGLE_COLUMN_BREAKPOINT,
  14. TWO_COLUMN_BREAKPOINT
  15. } from './constants';
  16. /**
  17. * Listens for changes in the number of participants to calculate the dimensions of the tile view grid and the tiles.
  18. */
  19. StateListenerRegistry.register(
  20. /* selector */ getParticipantCountWithFake,
  21. /* listener */ (numberOfParticipants, store) => {
  22. const state = store.getState();
  23. if (shouldDisplayTileView(state)) {
  24. const gridDimensions = getTileViewGridDimensions(state);
  25. const oldGridDimensions = state['features/filmstrip'].tileViewDimensions.gridDimensions;
  26. if (!equals(gridDimensions, oldGridDimensions)) {
  27. store.dispatch(setTileViewDimensions(gridDimensions));
  28. }
  29. }
  30. });
  31. /**
  32. * Listens for changes in the selected layout to calculate the dimensions of the tile view grid and horizontal view.
  33. */
  34. StateListenerRegistry.register(
  35. /* selector */ state => getCurrentLayout(state),
  36. /* listener */ (layout, store) => {
  37. const state = store.getState();
  38. switch (layout) {
  39. case LAYOUTS.TILE_VIEW:
  40. store.dispatch(setTileViewDimensions(getTileViewGridDimensions(state)));
  41. break;
  42. case LAYOUTS.HORIZONTAL_FILMSTRIP_VIEW:
  43. store.dispatch(setHorizontalViewDimensions());
  44. break;
  45. case LAYOUTS.VERTICAL_FILMSTRIP_VIEW:
  46. store.dispatch(setVerticalViewDimensions());
  47. break;
  48. }
  49. });
  50. /**
  51. * Listens for changes in the chat state to recompute available width.
  52. */
  53. StateListenerRegistry.register(
  54. /* selector */ state => state['features/chat'].isOpen,
  55. /* listener */ (isChatOpen, store) => {
  56. const { innerWidth, innerHeight } = window;
  57. if (isChatOpen) {
  58. // $FlowFixMe
  59. document.body.classList.add('shift-right');
  60. } else {
  61. // $FlowFixMe
  62. document.body.classList.remove('shift-right');
  63. }
  64. store.dispatch(clientResized(innerWidth, innerHeight));
  65. });
  66. /**
  67. * Listens for changes in the participant pane state to calculate the
  68. * dimensions of the tile view grid and the tiles.
  69. */
  70. StateListenerRegistry.register(
  71. /* selector */ getParticipantsPaneOpen,
  72. /* listener */ (isOpen, store) => {
  73. const { innerWidth, innerHeight } = window;
  74. store.dispatch(clientResized(innerWidth, innerHeight));
  75. });
  76. /**
  77. * Listens for changes in the client width to determine whether the overflow menu(s) should be displayed as drawers.
  78. */
  79. StateListenerRegistry.register(
  80. /* selector */ state => state['features/base/responsive-ui'].clientWidth < DISPLAY_DRAWER_THRESHOLD,
  81. /* listener */ (widthBelowThreshold, store) => {
  82. store.dispatch(setOverflowDrawer(widthBelowThreshold));
  83. });
  84. /**
  85. * Gracefully hide/show the filmstrip when going past threshold.
  86. */
  87. StateListenerRegistry.register(
  88. /* selector */ state => state['features/base/responsive-ui'].clientWidth < ASPECT_RATIO_BREAKPOINT,
  89. /* listener */ (widthBelowThreshold, store) => {
  90. const state = store.getState();
  91. const { disableFilmstripAutohiding } = state['features/base/config'];
  92. if (!disableFilmstripAutohiding) {
  93. store.dispatch(setFilmstripVisible(!widthBelowThreshold));
  94. }
  95. });
  96. /**
  97. * Symbol mapping used for the tile view responsiveness computation.
  98. */
  99. const responsiveColumnMapping = {
  100. multipleColumns: Symbol('multipleColumns'),
  101. singleColumn: Symbol('singleColumn'),
  102. twoColumns: Symbol('twoColumns'),
  103. twoParticipantsSingleColumn: Symbol('twoParticipantsSingleColumn')
  104. };
  105. /**
  106. * Listens for changes in the screen size to recompute
  107. * the dimensions of the tile view grid and the tiles for responsiveness.
  108. */
  109. StateListenerRegistry.register(
  110. /* selector */ state => {
  111. const { clientWidth } = state['features/base/responsive-ui'];
  112. if (clientWidth < TWO_COLUMN_BREAKPOINT && clientWidth >= ASPECT_RATIO_BREAKPOINT) {
  113. // Forcing the recomputation of tiles when screen switches in or out of
  114. // the (TWO_COLUMN_BREAKPOINT, ASPECT_RATIO_BREAKPOINT] interval.
  115. return responsiveColumnMapping.twoColumns;
  116. } else if (clientWidth < ASPECT_RATIO_BREAKPOINT && clientWidth >= SINGLE_COLUMN_BREAKPOINT) {
  117. // Forcing the recomputation of tiles when screen switches in or out of
  118. // the (ASPECT_RATIO_BREAKPOINT, SINGLE_COLUMN_BREAKPOINT] interval.
  119. return responsiveColumnMapping.twoParticipantsSingleColumn;
  120. } else if (clientWidth < SINGLE_COLUMN_BREAKPOINT) {
  121. // Forcing the recomputation of tiles when screen switches below SINGLE_COLUMN_BREAKPOINT.
  122. return responsiveColumnMapping.singleColumn;
  123. }
  124. // Forcing the recomputation of tiles when screen switches above TWO_COLUMN_BREAKPOINT.
  125. return responsiveColumnMapping.multipleColumns;
  126. },
  127. /* listener */ (_, store) => {
  128. const state = store.getState();
  129. if (shouldDisplayTileView(state)) {
  130. const gridDimensions = getTileViewGridDimensions(state);
  131. store.dispatch(setTileViewDimensions(gridDimensions));
  132. }
  133. });