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.

Subject.js 2.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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/functions.web';
  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 the conference timer should be shown or not.
  15. */
  16. _hideConferenceTimer: Boolean,
  17. /**
  18. * Whether the participant count should be shown or not.
  19. */
  20. _showParticipantCount: boolean,
  21. /**
  22. * The subject or the of the conference.
  23. * Falls back to conference name.
  24. */
  25. _subject: string,
  26. /**
  27. * Indicates whether the component should be visible or not.
  28. */
  29. _visible: boolean
  30. };
  31. /**
  32. * Subject react component.
  33. *
  34. * @class Subject
  35. */
  36. class Subject extends Component<Props> {
  37. /**
  38. * Implements React's {@link Component#render()}.
  39. *
  40. * @inheritdoc
  41. * @returns {ReactElement}
  42. */
  43. render() {
  44. const { _hideConferenceTimer, _showParticipantCount, _subject, _visible } = this.props;
  45. return (
  46. <div className = { `subject ${_visible ? 'visible' : ''}` }>
  47. <span className = 'subject-text'>{ _subject }</span>
  48. { _showParticipantCount && <ParticipantsCount /> }
  49. { !_hideConferenceTimer && <ConferenceTimer /> }
  50. </div>
  51. );
  52. }
  53. }
  54. /**
  55. * Maps (parts of) the Redux state to the associated
  56. * {@code Subject}'s props.
  57. *
  58. * @param {Object} state - The Redux state.
  59. * @private
  60. * @returns {{
  61. * _hideConferenceTimer: boolean,
  62. * _showParticipantCount: boolean,
  63. * _subject: string,
  64. * _visible: boolean
  65. * }}
  66. */
  67. function _mapStateToProps(state) {
  68. const participantCount = getParticipantCount(state);
  69. return {
  70. _hideConferenceTimer: Boolean(state['features/base/config'].hideConferenceTimer),
  71. _showParticipantCount: participantCount > 2,
  72. _subject: getConferenceName(state),
  73. _visible: isToolboxVisible(state) && participantCount > 1
  74. };
  75. }
  76. export default connect(_mapStateToProps)(Subject);