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

Subject.js 1.9KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. /* @flow */
  2. import React, { Component } from 'react';
  3. import { getConferenceName } from '../../../base/conference/functions';
  4. import { getParticipantCount } from '../../../base/participants/functions';
  5. import { connect } from '../../../base/redux';
  6. import { isToolboxVisible } from '../../../toolbox';
  7. import ConferenceTimer from '../ConferenceTimer';
  8. import ParticipantsCount from './ParticipantsCount';
  9. /**
  10. * The type of the React {@code Component} props of {@link Subject}.
  11. */
  12. type Props = {
  13. /**
  14. * Whether then participant count should be shown or not.
  15. */
  16. _showParticipantCount: boolean,
  17. /**
  18. * The subject or the of the conference.
  19. * Falls back to conference name.
  20. */
  21. _subject: string,
  22. /**
  23. * Indicates whether the component should be visible or not.
  24. */
  25. _visible: boolean
  26. };
  27. /**
  28. * Subject react component.
  29. *
  30. * @class Subject
  31. */
  32. class Subject extends Component<Props> {
  33. /**
  34. * Implements React's {@link Component#render()}.
  35. *
  36. * @inheritdoc
  37. * @returns {ReactElement}
  38. */
  39. render() {
  40. const { _showParticipantCount, _subject, _visible } = this.props;
  41. return (
  42. <div className = { `subject ${_visible ? 'visible' : ''}` }>
  43. <span className = 'subject-text'>{ _subject }</span>
  44. { _showParticipantCount && <ParticipantsCount /> }
  45. <ConferenceTimer />
  46. </div>
  47. );
  48. }
  49. }
  50. /**
  51. * Maps (parts of) the Redux state to the associated
  52. * {@code Subject}'s props.
  53. *
  54. * @param {Object} state - The Redux state.
  55. * @private
  56. * @returns {{
  57. * _subject: string,
  58. * _visible: boolean
  59. * }}
  60. */
  61. function _mapStateToProps(state) {
  62. const participantCount = getParticipantCount(state);
  63. return {
  64. _showParticipantCount: participantCount > 2,
  65. _subject: getConferenceName(state),
  66. _visible: isToolboxVisible(state)
  67. };
  68. }
  69. export default connect(_mapStateToProps)(Subject);