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

StopLiveStreamDialog.web.js 2.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. // @flow
  2. import React, { Component } from 'react';
  3. import { connect } from 'react-redux';
  4. import { Dialog } from '../../../base/dialog';
  5. import { translate } from '../../../base/i18n';
  6. import {
  7. createRecordingDialogEvent,
  8. sendAnalytics
  9. } from '../../../analytics';
  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. class StopLiveStreamDialog 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.props.t('dialog.stopStreamingWarning') }
  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. /**
  80. * Maps (parts of) the redux state to the React {@code Component} props of
  81. * {@code StopLiveStreamDialog}.
  82. *
  83. * @param {Object} state - The redux state.
  84. * @private
  85. * @returns {{
  86. * _conference: Object
  87. * }}
  88. */
  89. function _mapStateToProps(state) {
  90. return {
  91. _conference: state['features/base/conference'].conference
  92. };
  93. }
  94. export default translate(connect(_mapStateToProps)(StopLiveStreamDialog));