您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

ShareAudioDialog.tsx 3.6KB

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