Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

functions.native.js 3.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. // @flow
  2. import { getFeatureFlag, FILMSTRIP_ENABLED } from '../base/flags';
  3. import { getParticipantCountWithFake, getPinnedParticipant } from '../base/participants';
  4. import { toState } from '../base/redux';
  5. import { ASPECT_RATIO_NARROW } from '../base/responsive-ui/constants';
  6. export * from './functions.any';
  7. /**
  8. * Returns true if the filmstrip on mobile is visible, false otherwise.
  9. *
  10. * NOTE: Filmstrip on mobile behaves differently to web, and is only visible
  11. * when there are at least 2 participants.
  12. *
  13. * @param {Object | Function} stateful - The Object or Function that can be
  14. * resolved to a Redux state object with the toState function.
  15. * @returns {boolean}
  16. */
  17. export function isFilmstripVisible(stateful: Object | Function) {
  18. const state = toState(stateful);
  19. const enabled = getFeatureFlag(state, FILMSTRIP_ENABLED, true);
  20. if (!enabled) {
  21. return false;
  22. }
  23. return getParticipantCountWithFake(state) > 1;
  24. }
  25. /**
  26. * Determines whether the remote video thumbnails should be displayed/visible in
  27. * the filmstrip.
  28. *
  29. * @param {Object} state - The full redux state.
  30. * @returns {boolean} - If remote video thumbnails should be displayed/visible
  31. * in the filmstrip, then {@code true}; otherwise, {@code false}.
  32. */
  33. export function shouldRemoteVideosBeVisible(state: Object) {
  34. if (state['features/invite'].calleeInfoVisible) {
  35. return false;
  36. }
  37. // Include fake participants to derive how many thumbnails are dispalyed,
  38. // as it is assumed all participants, including fake, will be displayed
  39. // in the filmstrip.
  40. const participantCount = getParticipantCountWithFake(state);
  41. const pinnedParticipant = getPinnedParticipant(state);
  42. const { disable1On1Mode } = state['features/base/config'];
  43. return Boolean(
  44. participantCount > 2
  45. // Always show the filmstrip when there is another participant to
  46. // show and the local video is pinned. Note we are not taking the
  47. // toolbar visibility into account here (unlike web) because
  48. // showing / hiding views in quick succession on mobile is taxing.
  49. || (participantCount > 1 && pinnedParticipant?.local)
  50. || disable1On1Mode);
  51. }
  52. /**
  53. * Returns how many columns should be displayed for tile view.
  54. *
  55. * @param {Object | Function} stateful - The Object or Function that can be
  56. * resolved to a Redux state object with the toState function.
  57. * @returns {number} - The number of columns to be rendered in tile view.
  58. * @private
  59. */
  60. export function getColumnCount(stateful: Object | Function) {
  61. const state = toState(stateful);
  62. const participantCount = getParticipantCountWithFake(state);
  63. const { aspectRatio } = state['features/base/responsive-ui'];
  64. // For narrow view, tiles should stack on top of each other for a lonely
  65. // call and a 1:1 call. Otherwise tiles should be grouped into rows of
  66. // two.
  67. if (aspectRatio === ASPECT_RATIO_NARROW) {
  68. return participantCount >= 3 ? 2 : 1;
  69. }
  70. if (participantCount === 4) {
  71. // In wide view, a four person call should display as a 2x2 grid.
  72. return 2;
  73. }
  74. return Math.min(3, participantCount);
  75. }