您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

AbstractKnockingParticipantList.js 2.0KB

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