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

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