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

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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. getTileViewGridDimensions
  10. } from '../video-layout';
  11. import { SET_HORIZONTAL_VIEW_DIMENSIONS, SET_TILE_VIEW_DIMENSIONS } from './actionTypes';
  12. import { setHorizontalViewDimensions, setTileViewDimensions } from './actions';
  13. import './subscriber.web';
  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. try {
  38. setTimeout(window.resizeThumbnailsForCustomView,10)
  39. // window.resizeThumbnailsForCustomView()
  40. } catch (err){
  41. clog("window.resizeThumbnailsForCustomView ERR:",err)
  42. }
  43. break;
  44. }
  45. case SET_TILE_VIEW_DIMENSIONS: {
  46. const state = store.getState();
  47. if (shouldDisplayTileView(state)) {
  48. const { width, height } = state['features/filmstrip'].tileViewDimensions.thumbnailSize;
  49. // Once the thumbnails are reactified this should be moved there too.
  50. Filmstrip.resizeThumbnailsForTileView(width, height, true);
  51. }
  52. break;
  53. }
  54. case SET_HORIZONTAL_VIEW_DIMENSIONS: {
  55. const state = store.getState();
  56. if (getCurrentLayout(state) === LAYOUTS.HORIZONTAL_FILMSTRIP_VIEW) {
  57. const { horizontalViewDimensions = {} } = state['features/filmstrip'];
  58. // Once the thumbnails are reactified this should be moved there too.
  59. Filmstrip.resizeThumbnailsForHorizontalView(horizontalViewDimensions, true);
  60. }
  61. break;
  62. }
  63. }
  64. return result;
  65. });