2022-10-10 09:12:02 +00:00
|
|
|
import { WithTranslation } from 'react-i18next';
|
2021-02-24 21:45:07 +00:00
|
|
|
|
2022-10-20 09:11:27 +00:00
|
|
|
import { IReduxState } from '../../app/types';
|
2021-09-10 11:05:16 +00:00
|
|
|
import { requestDisableVideoModeration, requestEnableVideoModeration } from '../../av-moderation/actions';
|
2021-10-01 13:47:13 +00:00
|
|
|
import { isEnabledFromState, isSupported } from '../../av-moderation/functions';
|
2022-10-10 09:12:02 +00:00
|
|
|
import { MEDIA_TYPE } from '../../base/media/constants';
|
|
|
|
import { getLocalParticipant, getParticipantDisplayName } from '../../base/participants/functions';
|
2021-02-24 21:45:07 +00:00
|
|
|
import { muteAllParticipants } from '../actions';
|
|
|
|
|
|
|
|
import AbstractMuteRemoteParticipantsVideoDialog, {
|
|
|
|
type Props as AbstractProps
|
|
|
|
} from './AbstractMuteRemoteParticipantsVideoDialog';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The type of the React {@code Component} props of
|
|
|
|
* {@link AbstractMuteEveryonesVideoDialog}.
|
|
|
|
*/
|
2022-10-10 09:12:02 +00:00
|
|
|
export type Props = AbstractProps & WithTranslation & {
|
|
|
|
content: string;
|
|
|
|
exclude: Array<string>;
|
|
|
|
isModerationSupported: boolean;
|
|
|
|
isVideoModerationEnabled: boolean;
|
|
|
|
showAdvancedModerationToggle: boolean;
|
|
|
|
title: string;
|
2021-09-10 11:05:16 +00:00
|
|
|
};
|
|
|
|
|
2022-11-03 08:35:51 +00:00
|
|
|
interface IState {
|
2021-09-10 11:05:16 +00:00
|
|
|
content: string;
|
2022-10-10 09:12:02 +00:00
|
|
|
moderationEnabled: boolean;
|
2022-11-03 08:35:51 +00:00
|
|
|
}
|
2021-02-24 21:45:07 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* An abstract Component with the contents for a dialog that asks for confirmation
|
|
|
|
* from the user before disabling all remote participants cameras.
|
|
|
|
*
|
2021-11-04 21:10:43 +00:00
|
|
|
* @augments AbstractMuteRemoteParticipantsVideoDialog
|
2021-02-24 21:45:07 +00:00
|
|
|
*/
|
2022-10-10 09:12:02 +00:00
|
|
|
export default class AbstractMuteEveryonesVideoDialog<P extends Props>
|
2022-11-03 08:35:51 +00:00
|
|
|
extends AbstractMuteRemoteParticipantsVideoDialog<P, IState> {
|
2021-02-24 21:45:07 +00:00
|
|
|
static defaultProps = {
|
|
|
|
exclude: [],
|
|
|
|
muteLocal: false
|
|
|
|
};
|
|
|
|
|
2021-09-10 11:05:16 +00:00
|
|
|
/**
|
|
|
|
* Initializes a new {@code AbstractMuteRemoteParticipantsVideoDialog} instance.
|
|
|
|
*
|
|
|
|
* @param {Object} props - The read-only properties with which the new
|
|
|
|
* instance is to be initialized.
|
|
|
|
*/
|
|
|
|
constructor(props: P) {
|
|
|
|
super(props);
|
|
|
|
|
|
|
|
this.state = {
|
|
|
|
moderationEnabled: props.isVideoModerationEnabled,
|
|
|
|
content: props.content || props.t(props.isVideoModerationEnabled
|
|
|
|
? 'dialog.muteEveryonesVideoDialogModerationOn' : 'dialog.muteEveryonesVideoDialog'
|
|
|
|
)
|
|
|
|
};
|
|
|
|
|
|
|
|
// Bind event handlers so they are only bound once per instance.
|
|
|
|
this._onSubmit = this._onSubmit.bind(this);
|
|
|
|
this._onToggleModeration = this._onToggleModeration.bind(this);
|
|
|
|
}
|
|
|
|
|
2021-02-24 21:45:07 +00:00
|
|
|
/**
|
2022-10-10 09:12:02 +00:00
|
|
|
* Toggles advanced moderation switch.
|
2021-02-24 21:45:07 +00:00
|
|
|
*
|
2022-10-10 09:12:02 +00:00
|
|
|
* @returns {void}
|
2021-02-24 21:45:07 +00:00
|
|
|
*/
|
2022-10-10 09:12:02 +00:00
|
|
|
_onToggleModeration() {
|
|
|
|
this.setState(state => {
|
|
|
|
return {
|
|
|
|
moderationEnabled: !state.moderationEnabled,
|
|
|
|
content: this.props.t(state.moderationEnabled
|
|
|
|
? 'dialog.muteEveryonesVideoDialog' : 'dialog.muteEveryonesVideoDialogModerationOn'
|
|
|
|
)
|
|
|
|
};
|
|
|
|
});
|
2021-02-24 21:45:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Callback to be invoked when the value of this dialog is submitted.
|
|
|
|
*
|
|
|
|
* @returns {boolean}
|
|
|
|
*/
|
|
|
|
_onSubmit() {
|
|
|
|
const {
|
|
|
|
dispatch,
|
|
|
|
exclude
|
|
|
|
} = this.props;
|
|
|
|
|
|
|
|
dispatch(muteAllParticipants(exclude, MEDIA_TYPE.VIDEO));
|
2021-09-10 11:05:16 +00:00
|
|
|
if (this.state.moderationEnabled) {
|
|
|
|
dispatch(requestEnableVideoModeration());
|
2021-09-22 12:25:55 +00:00
|
|
|
} else if (this.state.moderationEnabled !== undefined) {
|
2021-09-10 11:05:16 +00:00
|
|
|
dispatch(requestDisableVideoModeration());
|
|
|
|
}
|
2021-02-24 21:45:07 +00:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Maps (parts of) the Redux state to the associated {@code AbstractMuteEveryonesVideoDialog}'s props.
|
|
|
|
*
|
2022-10-20 09:11:27 +00:00
|
|
|
* @param {IReduxState} state - The redux state.
|
2021-02-24 21:45:07 +00:00
|
|
|
* @param {Object} ownProps - The properties explicitly passed to the component.
|
|
|
|
* @returns {Props}
|
|
|
|
*/
|
2022-10-20 09:11:27 +00:00
|
|
|
export function abstractMapStateToProps(state: IReduxState, ownProps: Props) {
|
2021-09-10 11:05:16 +00:00
|
|
|
const { exclude = [], t } = ownProps;
|
|
|
|
const isVideoModerationEnabled = isEnabledFromState(MEDIA_TYPE.VIDEO, state);
|
2021-02-24 21:45:07 +00:00
|
|
|
|
|
|
|
const whom = exclude
|
|
|
|
// eslint-disable-next-line no-confusing-arrow
|
2022-10-10 09:12:02 +00:00
|
|
|
.map(id => id === getLocalParticipant(state)?.id
|
2021-02-24 21:45:07 +00:00
|
|
|
? t('dialog.muteEveryoneSelf')
|
|
|
|
: getParticipantDisplayName(state, id))
|
|
|
|
.join(', ');
|
|
|
|
|
|
|
|
return whom.length ? {
|
|
|
|
content: t('dialog.muteEveryoneElsesVideoDialog'),
|
|
|
|
title: t('dialog.muteEveryoneElsesVideoTitle', { whom })
|
|
|
|
} : {
|
2021-09-10 11:05:16 +00:00
|
|
|
title: t('dialog.muteEveryonesVideoTitle'),
|
2021-10-01 13:47:13 +00:00
|
|
|
isVideoModerationEnabled,
|
|
|
|
isModerationSupported: isSupported()(state)
|
2021-02-24 21:45:07 +00:00
|
|
|
};
|
|
|
|
}
|