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

Labels.web.js 3.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. // @flow
  2. import React, { Component } from 'react';
  3. import { connect } from 'react-redux';
  4. import { RecordingLabel } from '../../recording';
  5. import { VideoQualityLabel } from '../../video-quality';
  6. /**
  7. * The type of the React {@code Component} props of {@link Labels}.
  8. */
  9. type Props = {
  10. /**
  11. * Whether or not the filmstrip is displayed with remote videos. Used to
  12. * determine display classes to set.
  13. */
  14. _filmstripVisible: boolean,
  15. /**
  16. * The redux state for all known recording sessions.
  17. */
  18. _recordingSessions: Array<Object>
  19. };
  20. /**
  21. * The type of the React {@code Component} state of {@link Labels}.
  22. */
  23. type State = {
  24. /**
  25. * Whether or not the filmstrip was not visible but has transitioned in the
  26. * latest component update to visible. This boolean is used to set a class
  27. * for position animations.
  28. *
  29. * @type {boolean}
  30. */
  31. filmstripBecomingVisible: boolean
  32. }
  33. /**
  34. * A container to hold video status labels, including recording status and
  35. * current large video quality.
  36. *
  37. * @extends Component
  38. */
  39. class Labels extends Component<Props, State> {
  40. /**
  41. * Initializes a new {@code Labels} instance.
  42. *
  43. * @param {Object} props - The read-only properties with which the new
  44. * instance is to be initialized.
  45. */
  46. constructor(props: Props) {
  47. super(props);
  48. this.state = {
  49. filmstripBecomingVisible: false
  50. };
  51. // Bind event handler so it is only bound once for every instance.
  52. this._renderRecordingLabel = this._renderRecordingLabel.bind(this);
  53. }
  54. /**
  55. * Updates the state for whether or not the filmstrip is being toggled to
  56. * display after having being hidden.
  57. *
  58. * @inheritdoc
  59. * @param {Object} nextProps - The read-only props which this Component will
  60. * receive.
  61. * @returns {void}
  62. */
  63. componentWillReceiveProps(nextProps) {
  64. this.setState({
  65. filmstripBecomingVisible: nextProps._filmstripVisible
  66. && !this.props._filmstripVisible
  67. });
  68. }
  69. /**
  70. * Implements React's {@link Component#render()}.
  71. *
  72. * @inheritdoc
  73. * @returns {ReactElement}
  74. */
  75. render() {
  76. const { _filmstripVisible, _recordingSessions } = this.props;
  77. const { filmstripBecomingVisible } = this.state;
  78. const className = `large-video-labels ${
  79. filmstripBecomingVisible ? 'opening' : ''} ${
  80. _filmstripVisible ? 'with-filmstrip' : 'without-filmstrip'}`;
  81. return (
  82. <div className = { className } >
  83. { _recordingSessions.map(this._renderRecordingLabel) }
  84. <VideoQualityLabel />
  85. </div>
  86. );
  87. }
  88. _renderRecordingLabel: (Object) => React$Node;
  89. /**
  90. * Renders a recording label.
  91. *
  92. * @param {Object} recordingSession - The recording session to render.
  93. * @private
  94. * @returns {ReactElement}
  95. */
  96. _renderRecordingLabel(recordingSession) {
  97. return (
  98. <RecordingLabel
  99. key = { recordingSession.id }
  100. session = { recordingSession } />
  101. );
  102. }
  103. }
  104. /**
  105. * Maps (parts of) the Redux state to the associated props for the
  106. * {@code Labels} component.
  107. *
  108. * @param {Object} state - The Redux state.
  109. * @private
  110. * @returns {{
  111. * _filmstripVisible: boolean,
  112. * _recordingSessions: Array<Object>
  113. * }}
  114. */
  115. function _mapStateToProps(state) {
  116. return {
  117. _filmstripVisible: state['features/filmstrip'].visible,
  118. _recordingSessions: state['features/recording'].sessionDatas
  119. };
  120. }
  121. export default connect(_mapStateToProps)(Labels);