feat(native-participants-pane) dialog for blocking audio/video

This commit is contained in:
Calin Chitu 2021-06-15 10:31:58 +03:00 committed by Hristo Terezov
parent b332fb474b
commit 1afae50923
5 changed files with 91 additions and 4 deletions

View File

@ -6,13 +6,14 @@ import { TouchableOpacity } from 'react-native';
import { Text } from 'react-native-paper'; import { Text } from 'react-native-paper';
import { useDispatch } from 'react-redux'; import { useDispatch } from 'react-redux';
import { hideDialog } from '../../../base/dialog'; import { openDialog, hideDialog } from '../../../base/dialog/actions';
import BottomSheet from '../../../base/dialog/components/native/BottomSheet'; import BottomSheet from '../../../base/dialog/components/native/BottomSheet';
import { import {
Icon, IconMicDisabledHollow, Icon, IconMicDisabledHollow,
IconVideoOff IconVideoOff
} from '../../../base/icons'; } from '../../../base/icons';
import { MEDIA_TYPE } from '../../../base/media'; import { MEDIA_TYPE } from '../../../base/media';
import { BlockAudioVideoDialog } from '../../../video-menu';
import { import {
muteAllParticipants muteAllParticipants
} from '../../../video-menu/actions.any'; } from '../../../video-menu/actions.any';
@ -33,6 +34,7 @@ type Props = {
export const ContextMenuMore = ({ exclude }: Props) => { export const ContextMenuMore = ({ exclude }: Props) => {
const dispatch = useDispatch(); const dispatch = useDispatch();
const blockAudioVideo = useCallback(() => dispatch(openDialog(BlockAudioVideoDialog)), [ dispatch ]);
const cancel = useCallback(() => dispatch(hideDialog()), [ dispatch ]); const cancel = useCallback(() => dispatch(hideDialog()), [ dispatch ]);
const muteEveryoneVideo = useCallback(() => dispatch(muteAllParticipants(exclude, MEDIA_TYPE.VIDEO)), [ dispatch ]); const muteEveryoneVideo = useCallback(() => dispatch(muteAllParticipants(exclude, MEDIA_TYPE.VIDEO)), [ dispatch ]);
const { t } = useTranslation(); const { t } = useTranslation();
@ -50,12 +52,13 @@ export const ContextMenuMore = ({ exclude }: Props) => {
<Text style = { styles.contextMenuItemText }>{t('participantsPane.actions.stopEveryonesVideo')}</Text> <Text style = { styles.contextMenuItemText }>{t('participantsPane.actions.stopEveryonesVideo')}</Text>
</TouchableOpacity> </TouchableOpacity>
<TouchableOpacity <TouchableOpacity
onPress = { blockAudioVideo }
style = { styles.contextMenuItem }> style = { styles.contextMenuItem }>
<Icon <Icon
size = { 20 } size = { 20 }
src = { IconMicDisabledHollow } src = { IconMicDisabledHollow }
style = { styles.contextMenuIcon } /> style = { styles.contextMenuIcon } />
<Text style = { styles.contextMenuItemText }>{t('participantsPane.actions.dontAllowUnmute')}</Text> <Text style = { styles.contextMenuItemText }>{t('participantsPane.actions.blockAudioVideo')}</Text>
</TouchableOpacity> </TouchableOpacity>
</BottomSheet> </BottomSheet>
); );

View File

@ -129,11 +129,11 @@ export function admitAllKnockingParticipants(knockingParticipants: Array<Object>
/** /**
* Don't allow participants to unmute. * Don't allow participants to unmute video/audio.
* *
* @returns {Function} * @returns {Function}
*/ */
export function dontAllowUnmute() { export function blockParticipantsAudioVideo() {
return (dispatch: Dispatch<any>, getState: Function) => { return (dispatch: Dispatch<any>, getState: Function) => {
const state = getState(); const state = getState();
const participants = state['features/base/participants']; const participants = state['features/base/participants'];

View File

@ -0,0 +1,51 @@
// @flow
import { Component } from 'react';
import { blockParticipantsAudioVideo } from '../actions.any';
type Props = {
/**
* The Redux dispatch function.
*/
dispatch: Function,
/**
* Function to translate i18n labels.
*/
t: Function
};
/**
* Abstract dialog to confirm blocking mic and camera for all participants.
*/
export default class AbstractBlockAudioVideoDialog
extends Component<Props> {
/**
* Initializes a new {@code AbstractBlockAudioVideoDialog} instance.
*
* @inheritdoc
*/
constructor(props: Props) {
super(props);
this._onSubmit = this._onSubmit.bind(this);
}
_onSubmit: () => boolean;
/**
* Callback for the confirm button.
*
* @private
* @returns {boolean} - True (to note that the modal should be closed).
*/
_onSubmit() {
const { dispatch } = this.props;
dispatch(blockParticipantsAudioVideo());
return true;
}
}

View File

@ -0,0 +1,32 @@
// @flow
import React from 'react';
import { ConfirmDialog } from '../../../base/dialog';
import { translate } from '../../../base/i18n';
import { connect } from '../../../base/redux';
import AbstractBlockAudioVideoDialog
from '../AbstractBlockAudioVideoDialog';
/**
* Dialog to confirm a remote participant kick action.
*/
class BlockAudioVideoDialog extends AbstractBlockAudioVideoDialog {
/**
* Implements React's {@link Component#render()}.
*
* @inheritdoc
* @returns {ReactElement}
*/
render() {
return (
<ConfirmDialog
contentKey = 'dialog.blockAudioVideoMsg'
onSubmit = { this._onSubmit } />
);
}
_onSubmit: () => boolean;
}
export default translate(connect()(BlockAudioVideoDialog));

View File

@ -1,5 +1,6 @@
// @flow // @flow
export { default as BlockAudioVideoDialog } from './BlockAudioVideoDialog';
export { default as GrantModeratorDialog } from './GrantModeratorDialog'; export { default as GrantModeratorDialog } from './GrantModeratorDialog';
export { default as KickRemoteParticipantDialog } from './KickRemoteParticipantDialog'; export { default as KickRemoteParticipantDialog } from './KickRemoteParticipantDialog';
export { default as MuteEveryoneDialog } from './MuteEveryoneDialog'; export { default as MuteEveryoneDialog } from './MuteEveryoneDialog';