2022-09-14 12:48:09 +00:00
|
|
|
import { IState } from '../app/types';
|
2022-10-04 13:02:49 +00:00
|
|
|
import { FEATURES_TO_BUTTONS_MAPPING } from '../base/jwt/constants';
|
|
|
|
import { isJwtFeatureEnabled } from '../base/jwt/functions';
|
2021-11-30 20:08:25 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Indicates if the audio mute button is disabled or not.
|
|
|
|
*
|
2022-09-14 12:48:09 +00:00
|
|
|
* @param {IState} state - The state from the Redux store.
|
2021-11-30 20:08:25 +00:00
|
|
|
* @returns {boolean}
|
|
|
|
*/
|
2022-09-14 12:48:09 +00:00
|
|
|
export function isAudioMuteButtonDisabled(state: IState) {
|
2021-12-07 21:48:12 +00:00
|
|
|
const { available, muted, unmuteBlocked } = state['features/base/media'].audio;
|
2022-04-18 13:19:19 +00:00
|
|
|
const { startSilent } = state['features/base/config'];
|
2021-11-30 20:08:25 +00:00
|
|
|
|
2022-04-26 12:32:18 +00:00
|
|
|
return Boolean(!available || startSilent || (muted && unmuteBlocked));
|
2021-11-30 20:08:25 +00:00
|
|
|
}
|
2022-10-04 13:02:49 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the buttons corresponding to features disabled through jwt.
|
|
|
|
*
|
|
|
|
* @param {IState} state - The state from the Redux store.
|
|
|
|
* @returns {string[]} - The disabled by jwt buttons array.
|
|
|
|
*/
|
|
|
|
export function getJwtDisabledButtons(state: IState) {
|
|
|
|
return Object.keys(FEATURES_TO_BUTTONS_MAPPING).reduce((acc: string[], current: string) => {
|
|
|
|
if (!isJwtFeatureEnabled(state, current, true)) {
|
|
|
|
acc.push(current);
|
|
|
|
}
|
|
|
|
|
|
|
|
return acc;
|
|
|
|
}, []);
|
|
|
|
}
|