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

AbstractStopLiveStreamDialog.js 2.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. // @flow
  2. import React, { Component } from 'react';
  3. import { Dialog } from '../../../base/dialog';
  4. import {
  5. createRecordingDialogEvent,
  6. sendAnalytics
  7. } from '../../../analytics';
  8. import { JitsiRecordingConstants } from '../../../base/lib-jitsi-meet';
  9. import { getActiveSession } from '../../functions';
  10. /**
  11. * The type of the React {@code Component} props of
  12. * {@link StopLiveStreamDialog}.
  13. */
  14. type Props = {
  15. /**
  16. * The {@code JitsiConference} for the current conference.
  17. */
  18. _conference: Object,
  19. /**
  20. * The redux representation of the live stremaing to be stopped.
  21. */
  22. _session: Object,
  23. /**
  24. * Invoked to obtain translated strings.
  25. */
  26. t: Function
  27. };
  28. /**
  29. * A React Component for confirming the participant wishes to stop the currently
  30. * active live stream of the conference.
  31. *
  32. * @extends Component
  33. */
  34. export default class AbstractStopLiveStreamDialog extends Component<Props> {
  35. /**
  36. * Initializes a new {@code StopLiveStreamDialog} instance.
  37. *
  38. * @param {Object} props - The read-only properties with which the new
  39. * instance is to be initialized.
  40. */
  41. constructor(props: Props) {
  42. super(props);
  43. // Bind event handler so it is only bound once for every instance.
  44. this._onSubmit = this._onSubmit.bind(this);
  45. }
  46. /**
  47. * Implements React's {@link Component#render()}.
  48. *
  49. * @inheritdoc
  50. * @returns {ReactElement}
  51. */
  52. render() {
  53. return (
  54. <Dialog
  55. okTitleKey = 'dialog.stopLiveStreaming'
  56. onSubmit = { this._onSubmit }
  57. titleKey = 'dialog.liveStreaming'
  58. width = 'small'>
  59. { this._renderDialogContent() }
  60. </Dialog>
  61. );
  62. }
  63. _onSubmit: () => boolean;
  64. /**
  65. * Callback invoked when stopping of live streaming is confirmed.
  66. *
  67. * @private
  68. * @returns {boolean} True to close the modal.
  69. */
  70. _onSubmit() {
  71. sendAnalytics(createRecordingDialogEvent('stop', 'confirm.button'));
  72. const { _session } = this.props;
  73. if (_session) {
  74. this.props._conference.stopRecording(_session.id);
  75. }
  76. return true;
  77. }
  78. /**
  79. * Function to be implemented by the platform specific implementations.
  80. *
  81. * @private
  82. * @returns {React$Component<*>}
  83. */
  84. _renderDialogContent: () => React$Component<*>
  85. }
  86. /**
  87. * Maps (parts of) the redux state to the React {@code Component} props of
  88. * {@code StopLiveStreamDialog}.
  89. *
  90. * @param {Object} state - The redux state.
  91. * @private
  92. * @returns {{
  93. * _conference: Object,
  94. * _session: Object
  95. * }}
  96. */
  97. export function _mapStateToProps(state: Object) {
  98. return {
  99. _conference: state['features/base/conference'].conference,
  100. _session: getActiveSession(state, JitsiRecordingConstants.mode.STREAM)
  101. };
  102. }