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.

ShareAudioDialog.tsx 3.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. import React, { Component } from 'react';
  2. import { WithTranslation } from 'react-i18next';
  3. import { IState, IStore } from '../../app/types';
  4. import { translate } from '../../base/i18n/functions';
  5. import { connect } from '../../base/redux/functions';
  6. import { updateSettings } from '../../base/settings/actions';
  7. import { shouldHideShareAudioHelper } from '../../base/settings/functions.any';
  8. // eslint-disable-next-line lines-around-comment
  9. // @ts-ignore
  10. import { toggleScreensharing } from '../../base/tracks/actions';
  11. import Checkbox from '../../base/ui/components/web/Checkbox';
  12. import Dialog from '../../base/ui/components/web/Dialog';
  13. /**
  14. * The type of the React {@code Component} props of {@link ShareAudioDialog}.
  15. */
  16. export interface Props extends WithTranslation {
  17. /**
  18. * Boolean stored in local storage that determines whether or not the dialog will be displayed again.
  19. */
  20. _shouldHideShareAudioHelper: boolean;
  21. /**
  22. * The redux {@code dispatch} function.
  23. */
  24. dispatch: IStore['dispatch'];
  25. }
  26. /**
  27. * Component that displays the audio screen share helper dialog.
  28. */
  29. class ShareAudioDialog extends Component<Props> {
  30. /**
  31. * Instantiates a new component.
  32. *
  33. * @inheritdoc
  34. */
  35. constructor(props: Props) {
  36. super(props);
  37. this._onContinue = this._onContinue.bind(this);
  38. this._onSelectHideShareAudioHelper = this._onSelectHideShareAudioHelper.bind(this);
  39. }
  40. /**
  41. * Continue the normal screen sharing flow when the user clicks continue.
  42. *
  43. * @returns {boolean}
  44. */
  45. _onContinue() {
  46. // Pass undefined as the first parameter so the underlying logic decides weather or not to stop screen sharing.
  47. this.props.dispatch(toggleScreensharing(undefined, true));
  48. return true;
  49. }
  50. /**
  51. * Callback invoked when the hide audio helper checkbox has been selected. This setting will be persisted in
  52. * the local storage, thus the dialog won't be displayed again.
  53. *
  54. * @param {Object} e - The key event to handle.
  55. * @returns {void}
  56. */
  57. _onSelectHideShareAudioHelper({ target: { checked } }: React.ChangeEvent<HTMLInputElement>) {
  58. this.props.dispatch(updateSettings({ hideShareAudioHelper: checked }));
  59. }
  60. /**
  61. * Implements {@Component#render}.
  62. *
  63. * @inheritdoc
  64. */
  65. render() {
  66. const { t } = this.props;
  67. return (
  68. <Dialog
  69. className = 'share-audio-dialog-container'
  70. ok = {{ translationKey: 'dialog.shareAudio' }}
  71. onSubmit = { this._onContinue }
  72. size = 'large'
  73. titleKey = { t('dialog.shareAudioTitle') }>
  74. <div className = 'share-audio-dialog'>
  75. <img
  76. className = 'share-audio-animation'
  77. src = 'images/share-audio.gif' />
  78. <Checkbox
  79. checked = { this.props._shouldHideShareAudioHelper }
  80. label = { t('dialog.hideShareAudioHelper') }
  81. name = 'hide-share-audio-helper'
  82. // eslint-disable-next-line react/jsx-no-bind
  83. onChange = { this._onSelectHideShareAudioHelper } />
  84. </div>
  85. </Dialog>
  86. );
  87. }
  88. }
  89. /**
  90. * Maps part of the Redux state to the props of this component.
  91. *
  92. * @param {IState} state - The Redux state.
  93. * @private
  94. * @returns {Props}
  95. */
  96. function _mapStateToProps(state: IState): Partial<Props> {
  97. return {
  98. _shouldHideShareAudioHelper: shouldHideShareAudioHelper(state)
  99. };
  100. }
  101. export default translate(connect(_mapStateToProps)(ShareAudioDialog));