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

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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 { isTranscribing } from '../transcribing/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. }
  17. /**
  18. * Returns the buttons corresponding to features disabled through jwt.
  19. *
  20. * @param {IReduxState} state - The state from the Redux store.
  21. * @param {string | undefined} jwt - The jwt token.
  22. * @param {ILocalParticipant} localParticipantFeatures - The features of the local participant.
  23. * @returns {string[]} - The disabled by jwt buttons array.
  24. */
  25. export function getJwtDisabledButtons(
  26. state: IReduxState,
  27. jwt: string | undefined,
  28. localParticipantFeatures?: IParticipantFeatures) {
  29. const acc = [];
  30. if (!isJwtFeatureEnabledStateless({
  31. jwt,
  32. localParticipantFeatures,
  33. feature: 'livestreaming',
  34. ifNoToken: true
  35. })) {
  36. acc.push('livestreaming');
  37. }
  38. if (!isTranscribing(state) && !isJwtFeatureEnabledStateless({
  39. jwt,
  40. localParticipantFeatures,
  41. feature: 'transcription',
  42. ifNoToken: true
  43. })) {
  44. acc.push('closedcaptions');
  45. }
  46. return acc;
  47. }