2020-04-15 13:13:43 +00:00
|
|
|
// @flow
|
|
|
|
|
|
|
|
import { PureComponent } from 'react';
|
|
|
|
|
|
|
|
import { isLocalParticipantModerator } from '../../base/participants';
|
|
|
|
import { setKnockingParticipantApproval } from '../actions';
|
|
|
|
|
2020-05-20 08:25:31 +00:00
|
|
|
export type Props = {
|
2020-04-15 13:13:43 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The list of participants.
|
|
|
|
*/
|
|
|
|
_participants: Array<Object>,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* True if the list should be rendered.
|
|
|
|
*/
|
|
|
|
_visible: boolean,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The Redux Dispatch function.
|
|
|
|
*/
|
|
|
|
dispatch: Function,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function to be used to translate i18n labels.
|
|
|
|
*/
|
|
|
|
t: Function
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Abstract class to encapsulate the platform common code of the {@code KnockingParticipantList}.
|
|
|
|
*/
|
2020-05-20 08:25:31 +00:00
|
|
|
export default class AbstractKnockingParticipantList<P: Props = Props> extends PureComponent<P> {
|
2020-04-15 13:13:43 +00:00
|
|
|
/**
|
|
|
|
* Instantiates a new component.
|
|
|
|
*
|
|
|
|
* @inheritdoc
|
|
|
|
*/
|
2020-05-20 08:25:31 +00:00
|
|
|
constructor(props: P) {
|
2020-04-15 13:13:43 +00:00
|
|
|
super(props);
|
|
|
|
|
|
|
|
this._onRespondToParticipant = this._onRespondToParticipant.bind(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
_onRespondToParticipant: (string, boolean) => Function;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function that constructs a callback for the response handler button.
|
|
|
|
*
|
|
|
|
* @param {string} id - The id of the knocking participant.
|
|
|
|
* @param {boolean} approve - The response for the knocking.
|
|
|
|
* @returns {Function}
|
|
|
|
*/
|
|
|
|
_onRespondToParticipant(id, approve) {
|
|
|
|
return () => {
|
|
|
|
this.props.dispatch(setKnockingParticipantApproval(id, approve));
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Maps part of the Redux state to the props of this component.
|
|
|
|
*
|
|
|
|
* @param {Object} state - The Redux state.
|
|
|
|
* @returns {Props}
|
|
|
|
*/
|
|
|
|
export function mapStateToProps(state: Object): $Shape<Props> {
|
2020-05-20 08:25:31 +00:00
|
|
|
const { knockingParticipants, lobbyEnabled } = state['features/lobby'];
|
2020-04-15 13:13:43 +00:00
|
|
|
|
|
|
|
return {
|
2020-05-20 08:25:31 +00:00
|
|
|
_participants: knockingParticipants,
|
|
|
|
_visible: lobbyEnabled && isLocalParticipantModerator(state) && Boolean(knockingParticipants.length)
|
2020-04-15 13:13:43 +00:00
|
|
|
};
|
|
|
|
}
|