2022-10-20 09:11:27 +00:00
|
|
|
import { IReduxState } 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-10-20 09:11:27 +00:00
|
|
|
* @param {IReduxState} state - The state from the Redux store.
|
2021-11-30 20:08:25 +00:00
|
|
|
* @returns {boolean}
|
|
|
|
*/
|
2022-10-20 09:11:27 +00:00
|
|
|
export function isAudioMuteButtonDisabled(state: IReduxState) {
|
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.
|
|
|
|
*
|
2022-10-20 09:11:27 +00:00
|
|
|
* @param {IReduxState} state - The state from the Redux store.
|
2022-10-04 13:02:49 +00:00
|
|
|
* @returns {string[]} - The disabled by jwt buttons array.
|
|
|
|
*/
|
2022-10-20 09:11:27 +00:00
|
|
|
export function getJwtDisabledButtons(state: IReduxState) {
|
2022-10-04 13:02:49 +00:00
|
|
|
return Object.keys(FEATURES_TO_BUTTONS_MAPPING).reduce((acc: string[], current: string) => {
|
|
|
|
if (!isJwtFeatureEnabled(state, current, true)) {
|
2022-10-06 15:01:53 +00:00
|
|
|
acc.push(FEATURES_TO_BUTTONS_MAPPING[current as keyof typeof FEATURES_TO_BUTTONS_MAPPING]);
|
2022-10-04 13:02:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return acc;
|
|
|
|
}, []);
|
|
|
|
}
|