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.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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. 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. const qualityLevel = getNearestReceiverVideoQualityLevel(height);
  50. store.dispatch(setMaxReceiverVideoQuality(qualityLevel));
  51. // Once the thumbnails are reactified this should be moved there too.
  52. Filmstrip.resizeThumbnailsForTileView(width, height, true);
  53. }
  54. break;
  55. }
  56. case SET_HORIZONTAL_VIEW_DIMENSIONS: {
  57. const state = store.getState();
  58. if (getCurrentLayout(state) === LAYOUTS.HORIZONTAL_FILMSTRIP_VIEW) {
  59. const { horizontalViewDimensions = {} } = state['features/filmstrip'];
  60. // Once the thumbnails are reactified this should be moved there too.
  61. Filmstrip.resizeThumbnailsForHorizontalView(horizontalViewDimensions, true);
  62. }
  63. break;
  64. }
  65. }
  66. return result;
  67. });