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

123456789101112131415161718192021222324252627282930313233
  1. import { IReduxState } from '../app/types';
  2. import { FEATURES_TO_BUTTONS_MAPPING } from '../base/jwt/constants';
  3. import { isJwtFeatureEnabled } from '../base/jwt/functions';
  4. import { IGUMPendingState } from '../base/media/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. *
  19. * @param {IReduxState} state - The state from the Redux store.
  20. * @returns {string[]} - The disabled by jwt buttons array.
  21. */
  22. export function getJwtDisabledButtons(state: IReduxState) {
  23. return Object.keys(FEATURES_TO_BUTTONS_MAPPING).reduce((acc: string[], current: string) => {
  24. if (!isJwtFeatureEnabled(state, current, true)) {
  25. acc.push(FEATURES_TO_BUTTONS_MAPPING[current as keyof typeof FEATURES_TO_BUTTONS_MAPPING]);
  26. }
  27. return acc;
  28. }, []);
  29. }