Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

AbstractRecordingLabel.js 2.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. // @flow
  2. import { Component } from 'react';
  3. import { JitsiRecordingConstants } from '../../base/lib-jitsi-meet';
  4. /**
  5. * NOTE: Web currently renders multiple indicators if multiple recording
  6. * sessions are running. This is however may not be a good UX as it's not
  7. * obvious why there are multiple similar 'REC' indicators rendered. Mobile
  8. * only renders one indicator if there is at least one recording session
  9. * running. These boolean are shared across the two components to make it
  10. * easier to align web's behaviour to mobile's later if necessary.
  11. */
  12. export type Props = {
  13. /**
  14. * True if there is an active recording with the provided mode therefore the
  15. * component must be rendered.
  16. */
  17. _visible: boolean,
  18. /**
  19. * The recording mode this indicator should display.
  20. */
  21. mode: string,
  22. /**
  23. * Invoked to obtain translated strings.
  24. */
  25. t: Function
  26. };
  27. /**
  28. * Abstract class for the {@code RecordingLabel} component.
  29. */
  30. export default class AbstractRecordingLabel<P: Props>
  31. extends Component<P> {
  32. /**
  33. * Implements React {@code Component}'s render.
  34. *
  35. * @inheritdoc
  36. */
  37. render() {
  38. return this.props._visible ? this._renderLabel() : null;
  39. }
  40. _getLabelKey: () => ?string
  41. /**
  42. * Returns the label key that this indicator should render.
  43. *
  44. * @protected
  45. * @returns {?string}
  46. */
  47. _getLabelKey() {
  48. switch (this.props.mode) {
  49. case JitsiRecordingConstants.mode.STREAM:
  50. return 'recording.live';
  51. case JitsiRecordingConstants.mode.FILE:
  52. return 'recording.rec';
  53. default:
  54. // Invalid mode is passed to the component.
  55. return undefined;
  56. }
  57. }
  58. /**
  59. * Renders the platform specific label component.
  60. *
  61. * @protected
  62. * @returns {React$Element}
  63. */
  64. _renderLabel: () => React$Element<*>
  65. }
  66. /**
  67. * Maps (parts of) the Redux state to the associated
  68. * {@code AbstractRecordingLabel}'s props.
  69. *
  70. * @param {Object} state - The Redux state.
  71. * @param {Props} ownProps - The component's own props.
  72. * @private
  73. * @returns {{
  74. * _visible: boolean
  75. * }}
  76. */
  77. export function _mapStateToProps(state: Object, ownProps: Props) {
  78. const { mode } = ownProps;
  79. const _recordingSessions = state['features/recording'].sessionDatas;
  80. const _visible
  81. = Array.isArray(_recordingSessions)
  82. && _recordingSessions.some(
  83. session => session.status === JitsiRecordingConstants.status.ON
  84. && session.mode === mode
  85. );
  86. return {
  87. _visible
  88. };
  89. }