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.

SoundsTab.tsx 5.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. /* eslint-disable lines-around-comment */
  2. import React from 'react';
  3. import { WithTranslation } from 'react-i18next';
  4. // @ts-ignore
  5. import { AbstractDialogTab } from '../../../base/dialog';
  6. // @ts-ignore
  7. import type { Props as AbstractDialogTabProps } from '../../../base/dialog';
  8. import { translate } from '../../../base/i18n/functions';
  9. import Checkbox from '../../../base/ui/components/web/Checkbox';
  10. /**
  11. * The type of the React {@code Component} props of {@link SoundsTab}.
  12. */
  13. export type Props = AbstractDialogTabProps & WithTranslation & {
  14. /**
  15. * Whether or not the reactions feature is enabled.
  16. */
  17. enableReactions: Boolean;
  18. /**
  19. * Whether or not moderator muted the sounds.
  20. */
  21. moderatorMutedSoundsReactions: Boolean;
  22. /**
  23. * Whether or not the sound for the incoming message should play.
  24. */
  25. soundsIncomingMessage: Boolean;
  26. /**
  27. * Whether or not the sound for the participant joined should play.
  28. */
  29. soundsParticipantJoined: Boolean;
  30. /**
  31. * Whether or not the sound for the participant entering the lobby should play.
  32. */
  33. soundsParticipantKnocking: Boolean;
  34. /**
  35. * Whether or not the sound for the participant left should play.
  36. */
  37. soundsParticipantLeft: Boolean;
  38. /**
  39. * Whether or not the sound for reactions should play.
  40. */
  41. soundsReactions: Boolean;
  42. /**
  43. * Whether or not the sound for the talk while muted notification should play.
  44. */
  45. soundsTalkWhileMuted: Boolean;
  46. /**
  47. * Invoked to obtain translated strings.
  48. */
  49. t: Function;
  50. };
  51. /**
  52. * React {@code Component} for modifying the local user's sound settings.
  53. *
  54. * @augments Component
  55. */
  56. class SoundsTab extends AbstractDialogTab<Props> {
  57. /**
  58. * Initializes a new {@code SoundsTab} instance.
  59. *
  60. * @param {Props} props - The React {@code Component} props to initialize
  61. * the new {@code SoundsTab} instance with.
  62. */
  63. constructor(props: Props) {
  64. super(props);
  65. // Bind event handlers so they are only bound once for every instance.
  66. this._onChange = this._onChange.bind(this);
  67. }
  68. /**
  69. * Changes a sound setting state.
  70. *
  71. * @param {Object} e - The key event to handle.
  72. *
  73. * @returns {void}
  74. */
  75. _onChange({ target }: React.ChangeEvent<HTMLInputElement>) {
  76. super._onChange({ [target.name]: target.checked });
  77. }
  78. /**
  79. * Implements React's {@link Component#render()}.
  80. *
  81. * @inheritdoc
  82. * @returns {ReactElement}
  83. */
  84. render() {
  85. const {
  86. soundsIncomingMessage,
  87. soundsParticipantJoined,
  88. soundsParticipantKnocking,
  89. soundsParticipantLeft,
  90. soundsTalkWhileMuted,
  91. soundsReactions,
  92. enableReactions,
  93. moderatorMutedSoundsReactions,
  94. t // @ts-ignore
  95. } = this.props;
  96. return (
  97. <div
  98. className = 'settings-sub-pane-element'
  99. key = 'sounds'>
  100. <h2 className = 'mock-atlaskit-label'>
  101. {t('settings.playSounds')}
  102. </h2>
  103. {enableReactions && <Checkbox
  104. checked = { soundsReactions }
  105. className = 'settings-checkbox'
  106. disabled = { moderatorMutedSoundsReactions }
  107. label = { t('settings.reactions') }
  108. name = 'soundsReactions'
  109. onChange = { this._onChange } />
  110. }
  111. <Checkbox
  112. checked = { soundsIncomingMessage }
  113. className = 'settings-checkbox'
  114. label = { t('settings.incomingMessage') }
  115. name = 'soundsIncomingMessage'
  116. onChange = { this._onChange } />
  117. <Checkbox
  118. checked = { soundsParticipantJoined }
  119. className = 'settings-checkbox'
  120. label = { t('settings.participantJoined') }
  121. name = 'soundsParticipantJoined'
  122. onChange = { this._onChange } />
  123. <Checkbox
  124. checked = { soundsParticipantLeft }
  125. className = 'settings-checkbox'
  126. label = { t('settings.participantLeft') }
  127. name = 'soundsParticipantLeft'
  128. onChange = { this._onChange } />
  129. <Checkbox
  130. checked = { soundsTalkWhileMuted }
  131. className = 'settings-checkbox'
  132. label = { t('settings.talkWhileMuted') }
  133. name = 'soundsTalkWhileMuted'
  134. onChange = { this._onChange } />
  135. <Checkbox
  136. checked = { soundsParticipantKnocking }
  137. className = 'settings-checkbox'
  138. label = { t('settings.participantKnocking') }
  139. name = 'soundsParticipantKnocking'
  140. onChange = { this._onChange } />
  141. </div>
  142. );
  143. }
  144. }
  145. // @ts-ignore
  146. export default translate(SoundsTab);