2022-10-20 12:11:27 +03:00
|
|
|
import { IReduxState } from '../app/types';
|
2024-05-22 13:36:53 -05:00
|
|
|
import { isJwtFeatureEnabledStateless } from '../base/jwt/functions';
|
2023-05-18 14:16:37 -05:00
|
|
|
import { IGUMPendingState } from '../base/media/types';
|
2024-05-22 13:36:53 -05:00
|
|
|
import { IParticipantFeatures } from '../base/participants/types';
|
2024-12-06 12:28:29 -06:00
|
|
|
import { iAmVisitor } from '../visitors/functions';
|
2021-11-30 15:08:25 -05:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Indicates if the audio mute button is disabled or not.
|
|
|
|
|
*
|
2022-10-20 12:11:27 +03:00
|
|
|
* @param {IReduxState} state - The state from the Redux store.
|
2021-11-30 15:08:25 -05:00
|
|
|
* @returns {boolean}
|
|
|
|
|
*/
|
2022-10-20 12:11:27 +03:00
|
|
|
export function isAudioMuteButtonDisabled(state: IReduxState) {
|
2023-05-18 14:16:37 -05:00
|
|
|
const { available, muted, unmuteBlocked, gumPending } = state['features/base/media'].audio;
|
2022-04-18 16:19:19 +03:00
|
|
|
const { startSilent } = state['features/base/config'];
|
2021-11-30 15:08:25 -05:00
|
|
|
|
2024-12-06 12:28:29 -06:00
|
|
|
return Boolean(!available || startSilent || (muted && unmuteBlocked) || gumPending !== IGUMPendingState.NONE
|
|
|
|
|
|| iAmVisitor(state));
|
2021-11-30 15:08:25 -05:00
|
|
|
}
|
2022-10-04 16:02:49 +03:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Returns the buttons corresponding to features disabled through jwt.
|
2024-10-02 17:43:00 -05:00
|
|
|
* This function is stateless as it returns a new array and may cause re-rendering.
|
2022-10-04 16:02:49 +03:00
|
|
|
*
|
2024-10-02 17:43:00 -05:00
|
|
|
* @param {boolean} isTranscribing - Whether there is currently a transcriber in the meeting.
|
2024-09-30 21:45:33 -05:00
|
|
|
* @param {boolean} isModerator - Whether local participant is moderator.
|
2024-05-22 13:36:53 -05:00
|
|
|
* @param {string | undefined} jwt - The jwt token.
|
|
|
|
|
* @param {ILocalParticipant} localParticipantFeatures - The features of the local participant.
|
2022-10-04 16:02:49 +03:00
|
|
|
* @returns {string[]} - The disabled by jwt buttons array.
|
|
|
|
|
*/
|
2024-09-13 18:35:34 -05:00
|
|
|
export function getJwtDisabledButtons(
|
2024-10-02 17:43:00 -05:00
|
|
|
isTranscribing: boolean,
|
2024-09-30 21:45:33 -05:00
|
|
|
isModerator: boolean,
|
2024-09-13 18:35:34 -05:00
|
|
|
jwt: string | undefined,
|
|
|
|
|
localParticipantFeatures?: IParticipantFeatures) {
|
|
|
|
|
const acc = [];
|
|
|
|
|
|
|
|
|
|
if (!isJwtFeatureEnabledStateless({
|
|
|
|
|
jwt,
|
|
|
|
|
localParticipantFeatures,
|
|
|
|
|
feature: 'livestreaming',
|
2024-09-30 21:45:33 -05:00
|
|
|
ifNoToken: isModerator,
|
2024-10-01 15:25:25 -05:00
|
|
|
ifNotInFeatures: false
|
2024-09-13 18:35:34 -05:00
|
|
|
})) {
|
|
|
|
|
acc.push('livestreaming');
|
|
|
|
|
}
|
|
|
|
|
|
2024-10-02 17:43:00 -05:00
|
|
|
if (!isTranscribing && !isJwtFeatureEnabledStateless({
|
2024-09-13 18:35:34 -05:00
|
|
|
jwt,
|
|
|
|
|
localParticipantFeatures,
|
|
|
|
|
feature: 'transcription',
|
2024-09-30 21:45:33 -05:00
|
|
|
ifNoToken: isModerator,
|
2024-10-01 15:25:25 -05:00
|
|
|
ifNotInFeatures: false
|
2024-09-13 18:35:34 -05:00
|
|
|
})) {
|
|
|
|
|
acc.push('closedcaptions');
|
|
|
|
|
}
|
2022-10-04 16:02:49 +03:00
|
|
|
|
2024-09-13 18:35:34 -05:00
|
|
|
return acc;
|
2022-10-04 16:02:49 +03:00
|
|
|
}
|