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

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