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 2.0KB

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