You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

AbstractKnockingParticipantList.js 1.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. // @flow
  2. import { PureComponent } from 'react';
  3. import { isLocalParticipantModerator } from '../../base/participants';
  4. import { setKnockingParticipantApproval } from '../actions';
  5. export type Props = {
  6. /**
  7. * The list of participants.
  8. */
  9. _participants: Array<Object>,
  10. /**
  11. * True if the list should be rendered.
  12. */
  13. _visible: boolean,
  14. /**
  15. * The Redux Dispatch function.
  16. */
  17. dispatch: Function,
  18. /**
  19. * Function to be used to translate i18n labels.
  20. */
  21. t: Function
  22. };
  23. /**
  24. * Abstract class to encapsulate the platform common code of the {@code KnockingParticipantList}.
  25. */
  26. export default class AbstractKnockingParticipantList<P: Props = Props> extends PureComponent<P> {
  27. /**
  28. * Instantiates a new component.
  29. *
  30. * @inheritdoc
  31. */
  32. constructor(props: P) {
  33. super(props);
  34. this._onRespondToParticipant = this._onRespondToParticipant.bind(this);
  35. }
  36. _onRespondToParticipant: (string, boolean) => Function;
  37. /**
  38. * Function that constructs a callback for the response handler button.
  39. *
  40. * @param {string} id - The id of the knocking participant.
  41. * @param {boolean} approve - The response for the knocking.
  42. * @returns {Function}
  43. */
  44. _onRespondToParticipant(id, approve) {
  45. return () => {
  46. this.props.dispatch(setKnockingParticipantApproval(id, approve));
  47. };
  48. }
  49. }
  50. /**
  51. * Maps part of the Redux state to the props of this component.
  52. *
  53. * @param {Object} state - The Redux state.
  54. * @returns {Props}
  55. */
  56. export function mapStateToProps(state: Object): $Shape<Props> {
  57. const { knockingParticipants, lobbyEnabled } = state['features/lobby'];
  58. return {
  59. _participants: knockingParticipants,
  60. _visible: lobbyEnabled && isLocalParticipantModerator(state) && Boolean(knockingParticipants.length)
  61. };
  62. }