fix(av-moderation) Fix Ask to Unmute on native

Show button with moderation off

Show "Allow video" instead of "Ask to unmute" when needed
This commit is contained in:
robertpin 2021-10-25 14:40:42 +03:00 committed by Horatiu Muresan
parent be5c397422
commit 53a05dd1ad
1 changed files with 46 additions and 5 deletions

View File

@ -1,8 +1,9 @@
// @flow
import { approveParticipant } from '../../../av-moderation/actions';
import { isSupported } from '../../../av-moderation/functions';
import { translate } from '../../../base/i18n';
import { IconMicrophone } from '../../../base/icons';
import { IconCamera, IconMicrophone } from '../../../base/icons';
import { MEDIA_TYPE } from '../../../base/media';
import { getParticipantById, isLocalParticipantModerator } from '../../../base/participants';
import { connect } from '../../../base/redux';
@ -16,11 +17,21 @@ export type Props = AbstractButtonProps & {
*/
dispatch: Function,
/**
* Whether or not the participant is audio force muted.
*/
isAudioForceMuted: boolean,
/**
* Whether or not the participant is video force muted.
*/
isVideoForceMuted: boolean,
/**
* The ID of the participant object that this button is supposed to
* ask to unmute.
*/
participantID: string,
participantID: string
};
/**
@ -31,6 +42,36 @@ class AskUnmuteButton extends AbstractButton<Props, *> {
icon = IconMicrophone;
label = 'participantsPane.actions.askUnmute';
/**
* Gets the current label.
*
* @returns {string}
*/
_getLabel() {
const { isAudioForceMuted, isVideoForceMuted } = this.props;
if (!isAudioForceMuted && isVideoForceMuted) {
return 'participantsPane.actions.allowVideo';
}
return this.label;
}
/**
* Gets the current icon.
*
* @returns {string}
*/
_getIcon() {
const { isAudioForceMuted, isVideoForceMuted } = this.props;
if (!isAudioForceMuted && isVideoForceMuted) {
return IconCamera;
}
return this.icon;
}
/**
* Handles clicking / pressing the button, and asks the participant to unmute.
*
@ -56,9 +97,9 @@ function mapStateToProps(state, ownProps) {
const participant = getParticipantById(state, participantID);
return {
visible: isLocalParticipantModerator(state)
&& (isForceMuted(participant, MEDIA_TYPE.AUDIO, state)
|| isForceMuted(participant, MEDIA_TYPE.VIDEO, state))
isAudioForceMuted: isForceMuted(participant, MEDIA_TYPE.AUDIO, state),
isVideoForceMuted: isForceMuted(participant, MEDIA_TYPE.VIDEO, state),
visible: isLocalParticipantModerator(state) && isSupported()
};
}