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.

middleware.web.js 2.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. // @flow
  2. import { getNearestReceiverVideoQualityLevel, setMaxReceiverVideoQuality } from '../base/conference';
  3. import { MiddlewareRegistry } from '../base/redux';
  4. import { CLIENT_RESIZED } from '../base/responsive-ui';
  5. import Filmstrip from '../../../modules/UI/videolayout/Filmstrip';
  6. import {
  7. getCurrentLayout,
  8. LAYOUTS,
  9. shouldDisplayTileView,
  10. getTileViewGridDimensions
  11. } from '../video-layout';
  12. import { setHorizontalViewDimensions, setTileViewDimensions } from './actions';
  13. import { SET_HORIZONTAL_VIEW_DIMENSIONS, SET_TILE_VIEW_DIMENSIONS } from './actionTypes';
  14. /**
  15. * The middleware of the feature Filmstrip.
  16. */
  17. MiddlewareRegistry.register(store => next => action => {
  18. const result = next(action);
  19. switch (action.type) {
  20. case CLIENT_RESIZED: {
  21. const state = store.getState();
  22. const layout = getCurrentLayout(state);
  23. switch (layout) {
  24. case LAYOUTS.TILE_VIEW: {
  25. const gridDimensions = getTileViewGridDimensions(state);
  26. const { clientHeight, clientWidth } = state['features/base/responsive-ui'];
  27. store.dispatch(setTileViewDimensions(gridDimensions, {
  28. clientHeight,
  29. clientWidth
  30. }));
  31. break;
  32. }
  33. case LAYOUTS.HORIZONTAL_FILMSTRIP_VIEW:
  34. store.dispatch(setHorizontalViewDimensions(state['features/base/responsive-ui'].clientHeight));
  35. break;
  36. }
  37. break;
  38. }
  39. case SET_TILE_VIEW_DIMENSIONS: {
  40. const state = store.getState();
  41. if (shouldDisplayTileView(state)) {
  42. const { width, height } = state['features/filmstrip'].tileViewDimensions.thumbnailSize;
  43. const qualityLevel = getNearestReceiverVideoQualityLevel(height);
  44. store.dispatch(setMaxReceiverVideoQuality(qualityLevel));
  45. // Once the thumbnails are reactified this should be moved there too.
  46. Filmstrip.resizeThumbnailsForTileView(width, height, true);
  47. }
  48. break;
  49. }
  50. case SET_HORIZONTAL_VIEW_DIMENSIONS: {
  51. const state = store.getState();
  52. if (getCurrentLayout(state) === LAYOUTS.HORIZONTAL_FILMSTRIP_VIEW) {
  53. const { horizontalViewDimensions = {} } = state['features/filmstrip'];
  54. // Once the thumbnails are reactified this should be moved there too.
  55. Filmstrip.resizeThumbnailsForHorizontalView(horizontalViewDimensions, true);
  56. }
  57. break;
  58. }
  59. }
  60. return result;
  61. });