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.6KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. import { IReduxState } from '../app/types';
  2. import { FEATURES_TO_BUTTONS_MAPPING } from '../base/jwt/constants';
  3. import { isJwtFeatureEnabledStateless } from '../base/jwt/functions';
  4. import { IGUMPendingState } from '../base/media/types';
  5. import { IParticipantFeatures } from '../base/participants/types';
  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 {string | undefined} jwt - The jwt token.
  21. * @param {ILocalParticipant} localParticipantFeatures - The features of the local participant.
  22. * @returns {string[]} - The disabled by jwt buttons array.
  23. */
  24. export function getJwtDisabledButtons(jwt: string | undefined, localParticipantFeatures?: IParticipantFeatures) {
  25. return Object.keys(FEATURES_TO_BUTTONS_MAPPING).reduce((acc: string[], current: string) => {
  26. if (!isJwtFeatureEnabledStateless({
  27. jwt,
  28. localParticipantFeatures,
  29. feature: current,
  30. ifNoToken: true
  31. })) {
  32. acc.push(FEATURES_TO_BUTTONS_MAPPING[current as keyof typeof FEATURES_TO_BUTTONS_MAPPING]);
  33. }
  34. return acc;
  35. }, []);
  36. }