Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

ModeratorSection.tsx 3.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. import React, { useCallback, useMemo } from 'react';
  2. import { useDispatch, useSelector } from 'react-redux';
  3. import { IReduxState } from '../../../app/types';
  4. import { setFollowMe, setStartMutedPolicy, setStartReactionsMuted } from '../../../base/conference/actions';
  5. import { updateSettings } from '../../../base/settings/actions';
  6. import Switch from '../../../base/ui/components/native/Switch';
  7. import { getModeratorTabProps } from '../../functions.native';
  8. import FormRow from './FormRow';
  9. import FormSection from './FormSection';
  10. const ModeratorSection = () => {
  11. const dispatch = useDispatch();
  12. const {
  13. followMeEnabled,
  14. startAudioMuted,
  15. startVideoMuted,
  16. startReactionsMuted
  17. } = useSelector((state: IReduxState) => getModeratorTabProps(state));
  18. const { disableReactionsModeration } = useSelector((state: IReduxState) => state['features/base/config']);
  19. const onStartAudioMutedToggled = useCallback((enabled?: boolean) => {
  20. dispatch(setStartMutedPolicy(
  21. Boolean(enabled), Boolean(startVideoMuted)));
  22. }, [ startVideoMuted, dispatch, setStartMutedPolicy ]);
  23. const onStartVideoMutedToggled = useCallback((enabled?: boolean) => {
  24. dispatch(setStartMutedPolicy(
  25. Boolean(startAudioMuted), Boolean(enabled)));
  26. }, [ startAudioMuted, dispatch, setStartMutedPolicy ]);
  27. const onFollowMeToggled = useCallback((enabled?: boolean) => {
  28. dispatch(setFollowMe(Boolean(enabled)));
  29. }, [ dispatch, setFollowMe ]);
  30. const onStartReactionsMutedToggled = useCallback((enabled?: boolean) => {
  31. dispatch(setStartReactionsMuted(Boolean(enabled), true));
  32. dispatch(updateSettings({ soundsReactions: enabled }));
  33. }, [ dispatch, updateSettings, setStartReactionsMuted ]);
  34. const moderationSettings = useMemo(() => {
  35. const moderation = [
  36. {
  37. label: 'settings.startAudioMuted',
  38. state: startAudioMuted,
  39. onChange: onStartAudioMutedToggled
  40. },
  41. {
  42. label: 'settings.startVideoMuted',
  43. state: startVideoMuted,
  44. onChange: onStartVideoMutedToggled
  45. },
  46. {
  47. label: 'settings.followMe',
  48. state: followMeEnabled,
  49. onChange: onFollowMeToggled
  50. },
  51. {
  52. label: 'settings.startReactionsMuted',
  53. state: startReactionsMuted,
  54. onChange: onStartReactionsMutedToggled
  55. }
  56. ];
  57. if (disableReactionsModeration) {
  58. moderation.pop();
  59. }
  60. return moderation;
  61. }, [ startAudioMuted,
  62. startVideoMuted,
  63. followMeEnabled,
  64. disableReactionsModeration,
  65. startReactionsMuted ]);
  66. return (
  67. <FormSection
  68. label = 'settings.playSounds'>
  69. {
  70. moderationSettings.map(({ label, state, onChange }) => (
  71. <FormRow
  72. key = { label }
  73. label = { label }>
  74. <Switch
  75. checked = { Boolean(state) }
  76. onChange = { onChange } />
  77. </FormRow>
  78. ))
  79. }
  80. </FormSection>
  81. );
  82. };
  83. export default ModeratorSection;