Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

ShareAudioDialog.tsx 3.6KB

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