feat(native-participants-pane) created admitAll action

This commit is contained in:
Calin Chitu 2021-06-08 18:43:10 +03:00 committed by Hristo Terezov
parent ba9398a1e2
commit 4b72fefd7e
4 changed files with 28 additions and 29 deletions

View File

@ -1,28 +1,5 @@
// @flow
import { getCurrentConference } from '../base/conference';
/**
* Approves (lets in) or rejects a knocking participant.
*
* @param {Function} getState - Function to get the Redux state.
* @param {string} id - The id of the knocking participant.
* @param {boolean} approved - True if the participant is approved, false otherwise.
* @returns {Function}
*/
export function setKnockingParticipantApproval(getState: Function, id: string, approved: boolean) {
const conference = getCurrentConference(getState());
if (conference) {
if (approved) {
conference.lobbyApproveAccess(id);
} else {
conference.lobbyDenyAccess(id);
}
}
}
/**
* Selector to return lobby state.
*

View File

@ -14,8 +14,7 @@ import {
} from '../../../base/icons';
import { MEDIA_TYPE } from '../../../base/media';
import {
muteAllParticipants,
unmuteDisabled
muteAllParticipants
} from '../../../video-menu/actions.any';
import styles from './styles';
@ -35,7 +34,6 @@ type Props = {
export const ContextMenuMore = ({ exclude }: Props) => {
const dispatch = useDispatch();
const cancel = useCallback(() => dispatch(hideDialog()), [ dispatch ]);
const unMuteDisabled = useCallback(() => dispatch(unmuteDisabled()), [ dispatch ]);
const muteEveryoneVideo = useCallback(() => dispatch(muteAllParticipants(exclude, MEDIA_TYPE.VIDEO)), [ dispatch ]);
const { t } = useTranslation();
@ -52,7 +50,6 @@ export const ContextMenuMore = ({ exclude }: Props) => {
<Text style = { styles.contextMenuItemText }>{t('participantsPane.actions.stopEveryonesVideo')}</Text>
</TouchableOpacity>
<TouchableOpacity
onPress = { unMuteDisabled }
style = { styles.contextMenuItem }>
<Icon
size = { 24 }

View File

@ -1,15 +1,20 @@
// @flow
import React from 'react';
import React, { useCallback } from 'react';
import { useTranslation } from 'react-i18next';
import { Text, View } from 'react-native';
import { Button } from 'react-native-paper';
import { useDispatch } from 'react-redux';
import { admitAllKnockingParticipants } from '../../../video-menu/actions.any';
import { LobbyParticipantItem } from './LobbyParticipantItem';
import { participants } from './participants';
import styles from './styles';
export const LobbyParticipantList = () => {
const dispatch = useDispatch();
const admitAll = useCallback(() => dispatch(admitAllKnockingParticipants()), [ dispatch ]);
const { t } = useTranslation();
return (
@ -21,7 +26,8 @@ export const LobbyParticipantList = () => {
</Text>
<Button
labelStyle = { styles.allParticipantActionsButton }
mode = 'text'>
mode = 'text'
onPress = { admitAll }>
{t('lobby.admitAll')}
</Button>
</View>

View File

@ -23,6 +23,8 @@ import {
getRemoteParticipants,
muteRemoteParticipant
} from '../base/participants';
import { setKnockingParticipantApproval } from '../lobby/actions';
import { getLobbyState } from '../lobby/functions';
declare var APP: Object;
@ -106,3 +108,20 @@ export function muteAllParticipants(exclude: Array<string>, mediaType: MEDIA_TYP
});
};
}
/**
* Admit all knocking participants.
*
* @returns {Function}
*/
export function admitAllKnockingParticipants() {
return (dispatch: Dispatch<any>, getState: Function) => {
const state = getState();
const { knockingParticipants, lobbyEnabled } = getLobbyState(state);
const knockingParticipantsIds = knockingParticipants.map(participant => participant.id);
knockingParticipantsIds
.map(id => lobbyEnabled && setKnockingParticipantApproval(id, true))
.map(dispatch);
};
}