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

1234567891011121314151617181920212223242526272829303132
  1. import { IReduxState } from '../app/types';
  2. import { FEATURES_TO_BUTTONS_MAPPING } from '../base/jwt/constants';
  3. import { isJwtFeatureEnabled } from '../base/jwt/functions';
  4. /**
  5. * Indicates if the audio mute button is disabled or not.
  6. *
  7. * @param {IReduxState} state - The state from the Redux store.
  8. * @returns {boolean}
  9. */
  10. export function isAudioMuteButtonDisabled(state: IReduxState) {
  11. const { available, muted, unmuteBlocked } = state['features/base/media'].audio;
  12. const { startSilent } = state['features/base/config'];
  13. return Boolean(!available || startSilent || (muted && unmuteBlocked));
  14. }
  15. /**
  16. * Returns the buttons corresponding to features disabled through jwt.
  17. *
  18. * @param {IReduxState} state - The state from the Redux store.
  19. * @returns {string[]} - The disabled by jwt buttons array.
  20. */
  21. export function getJwtDisabledButtons(state: IReduxState) {
  22. return Object.keys(FEATURES_TO_BUTTONS_MAPPING).reduce((acc: string[], current: string) => {
  23. if (!isJwtFeatureEnabled(state, current, true)) {
  24. acc.push(FEATURES_TO_BUTTONS_MAPPING[current as keyof typeof FEATURES_TO_BUTTONS_MAPPING]);
  25. }
  26. return acc;
  27. }, []);
  28. }