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.any.ts 2.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. import { IReduxState } from '../app/types';
  2. import { isJwtFeatureEnabledStateless } from '../base/jwt/functions';
  3. import { IGUMPendingState } from '../base/media/types';
  4. import { IParticipantFeatures } from '../base/participants/types';
  5. /**
  6. * Indicates if the audio mute button is disabled or not.
  7. *
  8. * @param {IReduxState} state - The state from the Redux store.
  9. * @returns {boolean}
  10. */
  11. export function isAudioMuteButtonDisabled(state: IReduxState) {
  12. const { available, muted, unmuteBlocked, gumPending } = state['features/base/media'].audio;
  13. const { startSilent } = state['features/base/config'];
  14. return Boolean(!available || startSilent || (muted && unmuteBlocked) || gumPending !== IGUMPendingState.NONE);
  15. }
  16. /**
  17. * Returns the buttons corresponding to features disabled through jwt.
  18. * This function is stateless as it returns a new array and may cause re-rendering.
  19. *
  20. * @param {boolean} isTranscribing - Whether there is currently a transcriber in the meeting.
  21. * @param {boolean} isModerator - Whether local participant is moderator.
  22. * @param {string | undefined} jwt - The jwt token.
  23. * @param {ILocalParticipant} localParticipantFeatures - The features of the local participant.
  24. * @returns {string[]} - The disabled by jwt buttons array.
  25. */
  26. export function getJwtDisabledButtons(
  27. isTranscribing: boolean,
  28. isModerator: boolean,
  29. jwt: string | undefined,
  30. localParticipantFeatures?: IParticipantFeatures) {
  31. const acc = [];
  32. if (!isJwtFeatureEnabledStateless({
  33. jwt,
  34. localParticipantFeatures,
  35. feature: 'livestreaming',
  36. ifNoToken: isModerator,
  37. ifNotInFeatures: false
  38. })) {
  39. acc.push('livestreaming');
  40. }
  41. if (!isTranscribing && !isJwtFeatureEnabledStateless({
  42. jwt,
  43. localParticipantFeatures,
  44. feature: 'transcription',
  45. ifNoToken: isModerator,
  46. ifNotInFeatures: false
  47. })) {
  48. acc.push('closedcaptions');
  49. }
  50. return acc;
  51. }