123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127 |
- import React, { useCallback, useMemo } from 'react';
- import { useDispatch, useSelector } from 'react-redux';
-
- import { IReduxState } from '../../../app/types';
- import {
- setFollowMe,
- setFollowMeRecorder,
- setStartMutedPolicy,
- setStartReactionsMuted
- } from '../../../base/conference/actions';
- import { updateSettings } from '../../../base/settings/actions';
- import Switch from '../../../base/ui/components/native/Switch';
- import { getModeratorTabProps } from '../../functions.native';
-
- import FormRow from './FormRow';
- import FormSection from './FormSection';
-
- const ModeratorSection = () => {
- const dispatch = useDispatch();
- const {
- followMeActive,
- followMeEnabled,
- followMeRecorderActive,
- followMeRecorderEnabled,
- startAudioMuted,
- startVideoMuted,
- startReactionsMuted
- } = useSelector((state: IReduxState) => getModeratorTabProps(state));
-
- const { disableReactionsModeration } = useSelector((state: IReduxState) => state['features/base/config']);
-
- const onStartAudioMutedToggled = useCallback((enabled?: boolean) => {
- dispatch(setStartMutedPolicy(
- Boolean(enabled), Boolean(startVideoMuted)));
- }, [ startVideoMuted, dispatch, setStartMutedPolicy ]);
-
- const onStartVideoMutedToggled = useCallback((enabled?: boolean) => {
- dispatch(setStartMutedPolicy(
- Boolean(startAudioMuted), Boolean(enabled)));
- }, [ startAudioMuted, dispatch, setStartMutedPolicy ]);
-
- const onFollowMeToggled = useCallback((enabled?: boolean) => {
- dispatch(setFollowMe(Boolean(enabled)));
- }, [ dispatch, setFollowMe ]);
-
- const onFollowMeRecorderToggled = useCallback((enabled?: boolean) => {
- dispatch(setFollowMeRecorder(Boolean(enabled)));
- }, [ dispatch, setFollowMeRecorder ]);
-
- const onStartReactionsMutedToggled = useCallback((enabled?: boolean) => {
- dispatch(setStartReactionsMuted(Boolean(enabled), true));
- dispatch(updateSettings({ soundsReactions: enabled }));
- }, [ dispatch, updateSettings, setStartReactionsMuted ]);
-
- const followMeRecorderChecked = followMeRecorderEnabled && !followMeRecorderActive;
-
- const moderationSettings = useMemo(() => {
- const moderation = [
- {
- disabled: false,
- label: 'settings.startAudioMuted',
- state: startAudioMuted,
- onChange: onStartAudioMutedToggled
- },
- {
- disabled: false,
- label: 'settings.startVideoMuted',
- state: startVideoMuted,
- onChange: onStartVideoMutedToggled
- },
- {
- disabled: followMeActive || followMeRecorderActive,
- label: 'settings.followMe',
- state: followMeEnabled && !followMeActive && !followMeRecorderChecked,
- onChange: onFollowMeToggled
- },
- {
- disabled: followMeRecorderActive || followMeActive,
- label: 'settings.followMeRecorder',
- state: followMeRecorderChecked,
- onChange: onFollowMeRecorderToggled
- },
- {
- disabled: false,
- label: 'settings.startReactionsMuted',
- state: startReactionsMuted,
- onChange: onStartReactionsMutedToggled
- }
- ];
-
- if (disableReactionsModeration) {
- moderation.pop();
- }
-
- return moderation;
- }, [ startAudioMuted,
- startVideoMuted,
- followMeEnabled,
- followMeRecorderEnabled,
- disableReactionsModeration,
- onStartAudioMutedToggled,
- onStartVideoMutedToggled,
- onFollowMeToggled,
- onFollowMeRecorderToggled,
- onStartReactionsMutedToggled,
- startReactionsMuted ]);
-
- return (
- <FormSection
- label = 'settings.playSounds'>
- {
- moderationSettings.map(({ label, state, onChange, disabled }) => (
- <FormRow
- key = { label }
- label = { label }>
- <Switch
- checked = { Boolean(state) }
- disabled = { disabled }
- onChange = { onChange } />
- </FormRow>
- ))
- }
- </FormSection>
- );
- };
-
- export default ModeratorSection;
|