Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

middleware.web.js 2.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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';
  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(setTileViewDimensions(gridDimensions, {
  27. clientHeight,
  28. clientWidth
  29. }));
  30. break;
  31. }
  32. case LAYOUTS.HORIZONTAL_FILMSTRIP_VIEW:
  33. store.dispatch(setHorizontalViewDimensions(state['features/base/responsive-ui'].clientHeight));
  34. break;
  35. }
  36. break;
  37. }
  38. case SET_TILE_VIEW_DIMENSIONS: {
  39. const state = store.getState();
  40. if (shouldDisplayTileView(state)) {
  41. const { width, height } = state['features/filmstrip'].tileViewDimensions.thumbnailSize;
  42. // Once the thumbnails are reactified this should be moved there too.
  43. Filmstrip.resizeThumbnailsForTileView(width, height, true);
  44. }
  45. break;
  46. }
  47. case SET_HORIZONTAL_VIEW_DIMENSIONS: {
  48. const state = store.getState();
  49. if (getCurrentLayout(state) === LAYOUTS.HORIZONTAL_FILMSTRIP_VIEW) {
  50. const { horizontalViewDimensions = {} } = state['features/filmstrip'];
  51. // Once the thumbnails are reactified this should be moved there too.
  52. Filmstrip.resizeThumbnailsForHorizontalView(horizontalViewDimensions, true);
  53. }
  54. break;
  55. }
  56. }
  57. return result;
  58. });