2021-06-03 16:23:18 +00:00
|
|
|
import React, { useCallback } from 'react';
|
|
|
|
import { useTranslation } from 'react-i18next';
|
2021-09-22 14:05:42 +00:00
|
|
|
import { TouchableOpacity, View } from 'react-native';
|
|
|
|
import { Divider, Text } from 'react-native-paper';
|
2021-06-29 14:05:11 +00:00
|
|
|
import { useDispatch, useSelector } from 'react-redux';
|
2021-06-03 16:23:18 +00:00
|
|
|
|
2021-09-22 14:05:42 +00:00
|
|
|
import {
|
|
|
|
requestDisableAudioModeration,
|
|
|
|
requestDisableVideoModeration,
|
|
|
|
requestEnableAudioModeration,
|
|
|
|
requestEnableVideoModeration
|
|
|
|
} from '../../../av-moderation/actions';
|
|
|
|
import {
|
2022-09-27 07:10:28 +00:00
|
|
|
isEnabled as isAvModerationEnabled,
|
|
|
|
isSupported as isAvModerationSupported
|
2021-09-22 14:05:42 +00:00
|
|
|
} from '../../../av-moderation/functions';
|
2022-09-27 07:10:28 +00:00
|
|
|
import { hideSheet, openDialog } from '../../../base/dialog/actions';
|
2021-06-03 16:23:18 +00:00
|
|
|
import BottomSheet from '../../../base/dialog/components/native/BottomSheet';
|
|
|
|
import {
|
2021-07-30 09:46:49 +00:00
|
|
|
Icon,
|
2021-09-22 14:05:42 +00:00
|
|
|
IconCheck,
|
2021-06-03 16:23:18 +00:00
|
|
|
IconVideoOff
|
|
|
|
} from '../../../base/icons';
|
2021-09-22 14:05:42 +00:00
|
|
|
import { MEDIA_TYPE } from '../../../base/media';
|
|
|
|
import { getParticipantCount, isEveryoneModerator } from '../../../base/participants';
|
2021-06-29 14:05:11 +00:00
|
|
|
import MuteEveryonesVideoDialog
|
|
|
|
from '../../../video-menu/components/native/MuteEveryonesVideoDialog';
|
2021-06-03 16:23:18 +00:00
|
|
|
|
|
|
|
import styles from './styles';
|
|
|
|
|
2021-06-29 14:05:11 +00:00
|
|
|
export const ContextMenuMore = () => {
|
2021-06-03 16:23:18 +00:00
|
|
|
const dispatch = useDispatch();
|
2022-06-20 14:53:19 +00:00
|
|
|
const muteAllVideo = useCallback(() => {
|
|
|
|
dispatch(openDialog(MuteEveryonesVideoDialog));
|
|
|
|
dispatch(hideSheet());
|
|
|
|
}, [ dispatch ]);
|
2021-06-03 16:23:18 +00:00
|
|
|
const { t } = useTranslation();
|
|
|
|
|
2022-05-19 08:43:36 +00:00
|
|
|
const isModerationSupported = useSelector(isAvModerationSupported);
|
2021-09-22 14:05:42 +00:00
|
|
|
const allModerators = useSelector(isEveryoneModerator);
|
|
|
|
const participantCount = useSelector(getParticipantCount);
|
|
|
|
|
|
|
|
const isAudioModerationEnabled = useSelector(isAvModerationEnabled(MEDIA_TYPE.AUDIO));
|
|
|
|
const isVideoModerationEnabled = useSelector(isAvModerationEnabled(MEDIA_TYPE.VIDEO));
|
|
|
|
|
|
|
|
const disableAudioModeration = useCallback(() => dispatch(requestDisableAudioModeration()), [ dispatch ]);
|
|
|
|
const disableVideoModeration = useCallback(() => dispatch(requestDisableVideoModeration()), [ dispatch ]);
|
|
|
|
|
|
|
|
const enableAudioModeration = useCallback(() => dispatch(requestEnableAudioModeration()), [ dispatch ]);
|
|
|
|
const enableVideoModeration = useCallback(() => dispatch(requestEnableVideoModeration()), [ dispatch ]);
|
|
|
|
|
2021-06-03 16:23:18 +00:00
|
|
|
return (
|
|
|
|
<BottomSheet
|
2021-07-06 19:07:52 +00:00
|
|
|
addScrollViewPadding = { false }
|
2021-09-22 14:05:42 +00:00
|
|
|
showSlidingView = { true }>
|
2021-06-03 16:23:18 +00:00
|
|
|
<TouchableOpacity
|
2021-06-29 14:05:11 +00:00
|
|
|
onPress = { muteAllVideo }
|
2021-06-04 15:07:18 +00:00
|
|
|
style = { styles.contextMenuItem }>
|
2021-06-03 16:23:18 +00:00
|
|
|
<Icon
|
2021-07-30 09:46:49 +00:00
|
|
|
size = { 24 }
|
2021-06-03 16:23:18 +00:00
|
|
|
src = { IconVideoOff } />
|
|
|
|
<Text style = { styles.contextMenuItemText }>{t('participantsPane.actions.stopEveryonesVideo')}</Text>
|
|
|
|
</TouchableOpacity>
|
2021-09-22 14:05:42 +00:00
|
|
|
{isModerationSupported && ((participantCount === 1 || !allModerators)) && <>
|
|
|
|
<Divider style = { styles.divider } />
|
|
|
|
<View style = { styles.contextMenuItem }>
|
|
|
|
<Text style = { styles.contextMenuItemText }>{t('participantsPane.actions.allow')}</Text>
|
|
|
|
</View>
|
|
|
|
{isAudioModerationEnabled
|
|
|
|
? <TouchableOpacity
|
|
|
|
onPress = { disableAudioModeration }
|
|
|
|
style = { styles.contextMenuItem }>
|
|
|
|
<Text style = { styles.contextMenuItemTextNoIcon }>
|
|
|
|
{t('participantsPane.actions.audioModeration')}
|
|
|
|
</Text>
|
|
|
|
</TouchableOpacity>
|
|
|
|
: <TouchableOpacity
|
|
|
|
onPress = { enableAudioModeration }
|
|
|
|
style = { styles.contextMenuItem }>
|
|
|
|
<Icon
|
|
|
|
size = { 24 }
|
|
|
|
src = { IconCheck } />
|
|
|
|
<Text style = { styles.contextMenuItemText }>
|
|
|
|
{t('participantsPane.actions.audioModeration')}
|
|
|
|
</Text>
|
|
|
|
</TouchableOpacity> }
|
|
|
|
{isVideoModerationEnabled
|
|
|
|
? <TouchableOpacity
|
|
|
|
onPress = { disableVideoModeration }
|
|
|
|
style = { styles.contextMenuItem }>
|
|
|
|
<Text style = { styles.contextMenuItemTextNoIcon }>
|
|
|
|
{t('participantsPane.actions.videoModeration')}
|
|
|
|
</Text>
|
|
|
|
</TouchableOpacity>
|
|
|
|
: <TouchableOpacity
|
|
|
|
onPress = { enableVideoModeration }
|
|
|
|
style = { styles.contextMenuItem }>
|
|
|
|
<Icon
|
|
|
|
size = { 24 }
|
|
|
|
src = { IconCheck } />
|
|
|
|
<Text style = { styles.contextMenuItemText }>
|
|
|
|
{t('participantsPane.actions.videoModeration')}
|
|
|
|
</Text>
|
|
|
|
</TouchableOpacity>}
|
|
|
|
</>}
|
2021-06-03 16:23:18 +00:00
|
|
|
</BottomSheet>
|
|
|
|
);
|
|
|
|
};
|