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

ShareAudioDialog.tsx 3.6KB

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