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

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