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.

functions.ts 1.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. import { IStateful } from '../base/app/types';
  2. import { getParticipantCount } from '../base/participants/functions';
  3. import { toState } from '../base/redux/functions';
  4. import { MAX_MODE_LIMIT, MAX_MODE_THRESHOLD } from './constants';
  5. /**
  6. * Gets the value of a specific React {@code Component} prop of the currently
  7. * mounted {@link App}.
  8. *
  9. * @param {IStateful} stateful - The redux store or {@code getState}
  10. * function.
  11. * @param {string} propName - The name of the React {@code Component} prop of
  12. * the currently mounted {@code App} to get.
  13. * @returns {*} The value of the specified React {@code Component} prop of the
  14. * currently mounted {@code App}.
  15. */
  16. export function doesEveryoneSupportE2EE(stateful: IStateful) {
  17. const state = toState(stateful);
  18. const { everyoneSupportE2EE } = state['features/e2ee'];
  19. const { e2eeSupported } = state['features/base/conference'];
  20. const participantCount = getParticipantCount(state);
  21. if (typeof everyoneSupportE2EE === 'undefined' && participantCount === 1) {
  22. // This will happen if we are alone.
  23. return e2eeSupported;
  24. }
  25. return everyoneSupportE2EE;
  26. }
  27. /**
  28. * Returns true is the number of participants is larger than {@code MAX_MODE_LIMIT}.
  29. *
  30. * @param {Function|Object} stateful - The redux store or {@code getState}
  31. * function.
  32. * @returns {boolean}.
  33. */
  34. export function isMaxModeReached(stateful: IStateful) {
  35. const participantCount = getParticipantCount(toState(stateful));
  36. return participantCount >= MAX_MODE_LIMIT;
  37. }
  38. /**
  39. * Returns true is the number of participants is larger than {@code MAX_MODE_LIMIT + MAX_MODE_THREHOLD}.
  40. *
  41. * @param {Function|Object} stateful - The redux store or {@code getState}
  42. * function.
  43. * @returns {boolean}.
  44. */
  45. export function isMaxModeThresholdReached(stateful: IStateful) {
  46. const participantCount = getParticipantCount(toState(stateful));
  47. return participantCount >= MAX_MODE_LIMIT + MAX_MODE_THRESHOLD;
  48. }