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.ts 2.4KB

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