Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

middleware.web.js 2.5KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. // @flow
  2. import Filmstrip from '../../../modules/UI/videolayout/Filmstrip';
  3. import { getNearestReceiverVideoQualityLevel, setMaxReceiverVideoQuality } from '../base/conference';
  4. import { MiddlewareRegistry } from '../base/redux';
  5. import { CLIENT_RESIZED } from '../base/responsive-ui';
  6. import {
  7. getCurrentLayout,
  8. LAYOUTS,
  9. shouldDisplayTileView
  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 } = state['features/filmstrip'].tileViewDimensions;
  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. });