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.

actions.web.js 2.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. // @flow
  2. import { toState } from '../base/redux';
  3. import { CHAT_SIZE } from '../chat/constants';
  4. import { SET_HORIZONTAL_VIEW_DIMENSIONS, SET_TILE_VIEW_DIMENSIONS } from './actionTypes';
  5. import { calculateThumbnailSizeForHorizontalView, calculateThumbnailSizeForTileView } from './functions';
  6. /**
  7. * The size of the side margins for the entire tile view area.
  8. */
  9. const TILE_VIEW_SIDE_MARGINS = 20;
  10. /**
  11. * Sets the dimensions of the tile view grid.
  12. *
  13. * @param {Object} dimensions - Whether the filmstrip is visible.
  14. * @param {Object} windowSize - The size of the window.
  15. * @param {Object | Function} stateful - An object or function that can be
  16. * resolved to Redux state using the {@code toState} function.
  17. * @returns {{
  18. * type: SET_TILE_VIEW_DIMENSIONS,
  19. * dimensions: Object
  20. * }}
  21. */
  22. export function setTileViewDimensions(dimensions: Object, windowSize: Object, stateful: Object | Function) {
  23. const state = toState(stateful);
  24. const { clientWidth, clientHeight } = windowSize;
  25. const heightToUse = clientHeight;
  26. let widthToUse = clientWidth;
  27. const { isOpen } = state['features/chat'];
  28. const { disableResponsiveTiles } = state['features/base/config'];
  29. if (isOpen) {
  30. widthToUse -= CHAT_SIZE;
  31. }
  32. const thumbnailSize = calculateThumbnailSizeForTileView({
  33. ...dimensions,
  34. clientWidth: widthToUse,
  35. clientHeight: heightToUse,
  36. disableResponsiveTiles
  37. });
  38. const filmstripWidth = dimensions.columns * (TILE_VIEW_SIDE_MARGINS + thumbnailSize.width);
  39. return {
  40. type: SET_TILE_VIEW_DIMENSIONS,
  41. dimensions: {
  42. gridDimensions: dimensions,
  43. thumbnailSize,
  44. filmstripWidth
  45. }
  46. };
  47. }
  48. /**
  49. * Sets the dimensions of the thumbnails in horizontal view.
  50. *
  51. * @param {number} clientHeight - The height of the window.
  52. * @returns {{
  53. * type: SET_HORIZONTAL_VIEW_DIMENSIONS,
  54. * dimensions: Object
  55. * }}
  56. */
  57. export function setHorizontalViewDimensions(clientHeight: number = 0) {
  58. return {
  59. type: SET_HORIZONTAL_VIEW_DIMENSIONS,
  60. dimensions: calculateThumbnailSizeForHorizontalView(clientHeight)
  61. };
  62. }
  63. export * from './actions.native';