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.

AbstractStopLiveStreamDialog.js 2.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. // @flow
  2. import { Component } from 'react';
  3. import {
  4. createLiveStreamingDialogEvent,
  5. sendAnalytics
  6. } from '../../../analytics';
  7. import { JitsiRecordingConstants } from '../../../base/lib-jitsi-meet';
  8. import { getActiveSession } from '../../functions';
  9. /**
  10. * The type of the React {@code Component} props of
  11. * {@link StopLiveStreamDialog}.
  12. */
  13. type Props = {
  14. /**
  15. * The {@code JitsiConference} for the current conference.
  16. */
  17. _conference: Object,
  18. /**
  19. * The redux representation of the live stremaing to be stopped.
  20. */
  21. _session: Object,
  22. /**
  23. * Invoked to obtain translated strings.
  24. */
  25. t: Function
  26. };
  27. /**
  28. * A React Component for confirming the participant wishes to stop the currently
  29. * active live stream of the conference.
  30. *
  31. * @augments Component
  32. */
  33. export default class AbstractStopLiveStreamDialog extends Component<Props> {
  34. /**
  35. * Initializes a new {@code StopLiveStreamDialog} instance.
  36. *
  37. * @param {Object} props - The read-only properties with which the new
  38. * instance is to be initialized.
  39. */
  40. constructor(props: Props) {
  41. super(props);
  42. // Bind event handler so it is only bound once for every instance.
  43. this._onSubmit = this._onSubmit.bind(this);
  44. }
  45. _onSubmit: () => boolean;
  46. /**
  47. * Callback invoked when stopping of live streaming is confirmed.
  48. *
  49. * @private
  50. * @returns {boolean} True to close the modal.
  51. */
  52. _onSubmit() {
  53. sendAnalytics(createLiveStreamingDialogEvent('stop', 'confirm.button'));
  54. const { _session } = this.props;
  55. if (_session) {
  56. this.props._conference.stopRecording(_session.id);
  57. }
  58. return true;
  59. }
  60. }
  61. /**
  62. * Maps (parts of) the redux state to the React {@code Component} props of
  63. * {@code StopLiveStreamDialog}.
  64. *
  65. * @param {Object} state - The redux state.
  66. * @private
  67. * @returns {{
  68. * _conference: Object,
  69. * _session: Object
  70. * }}
  71. */
  72. export function _mapStateToProps(state: Object) {
  73. return {
  74. _conference: state['features/base/conference'].conference,
  75. _session: getActiveSession(state, JitsiRecordingConstants.mode.STREAM)
  76. };
  77. }