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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. // @flow
  2. import { pinParticipant } from '../base/participants';
  3. import { toState } from '../base/redux';
  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 { disableResponsiveTiles } = state['features/base/config'];
  26. const thumbnailSize = calculateThumbnailSizeForTileView({
  27. ...dimensions,
  28. clientWidth,
  29. clientHeight,
  30. disableResponsiveTiles
  31. });
  32. const filmstripWidth = dimensions.columns * (TILE_VIEW_SIDE_MARGINS + thumbnailSize.width);
  33. return {
  34. type: SET_TILE_VIEW_DIMENSIONS,
  35. dimensions: {
  36. gridDimensions: dimensions,
  37. thumbnailSize,
  38. filmstripWidth
  39. }
  40. };
  41. }
  42. /**
  43. * Sets the dimensions of the thumbnails in horizontal view.
  44. *
  45. * @param {number} clientHeight - The height of the window.
  46. * @returns {{
  47. * type: SET_HORIZONTAL_VIEW_DIMENSIONS,
  48. * dimensions: Object
  49. * }}
  50. */
  51. export function setHorizontalViewDimensions(clientHeight: number = 0) {
  52. return {
  53. type: SET_HORIZONTAL_VIEW_DIMENSIONS,
  54. dimensions: calculateThumbnailSizeForHorizontalView(clientHeight)
  55. };
  56. }
  57. /**
  58. * Emulates a click on the n-th video.
  59. *
  60. * @param {number} n - Number that identifies the video.
  61. * @returns {Function}
  62. */
  63. export function clickOnVideo(n: number) {
  64. return (dispatch: Function, getState: Function) => {
  65. const participants = getState()['features/base/participants'];
  66. const nThParticipant = participants[n];
  67. const { id, pinned } = nThParticipant;
  68. dispatch(pinParticipant(pinned ? null : id));
  69. };
  70. }
  71. export * from './actions.native';