fix(virtual-background) display current settings (#13857)

pull/13861/head jitsi-meet_8968
Mihaela Dumitru 2 years ago committed by GitHub
parent 2952d1cde8
commit cb26042d08
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 57
      react/features/virtual-background/components/VirtualBackgrounds.tsx

@ -32,11 +32,6 @@ interface IProps extends WithTranslation {
*/ */
_images: Array<Image>; _images: Array<Image>;
/**
* The current local flip x status.
*/
_localFlipX: boolean;
/** /**
* Whether or not multi-stream send support is enabled. * Whether or not multi-stream send support is enabled.
*/ */
@ -47,24 +42,11 @@ interface IProps extends WithTranslation {
*/ */
_showUploadButton: boolean; _showUploadButton: boolean;
/**
* Returns the selected virtual background object.
*/
_virtualBackground: any;
/** /**
* The redux {@code dispatch} function. * The redux {@code dispatch} function.
*/ */
dispatch: IStore['dispatch']; dispatch: IStore['dispatch'];
/**
* The initial options copied in the state for the {@code VirtualBackground} component.
*
* NOTE: currently used only for electron in order to open the dialog in the correct state after desktop sharing
* selection.
*/
initialOptions?: Object;
/** /**
* Options change handler. * Options change handler.
*/ */
@ -205,13 +187,9 @@ const useStyles = makeStyles()(theme => {
*/ */
function VirtualBackgrounds({ function VirtualBackgrounds({
_images, _images,
_localFlipX,
selectedThumbnail,
_showUploadButton, _showUploadButton,
_virtualBackground,
onOptionsChange, onOptionsChange,
options, options,
initialOptions,
selectedVideoInputId, selectedVideoInputId,
t t
}: IProps) { }: IProps) {
@ -221,10 +199,6 @@ function VirtualBackgrounds({
const [ storedImages, setStoredImages ] = useState<Array<Image>>((localImages && safeJsonParse(localImages)) || []); const [ storedImages, setStoredImages ] = useState<Array<Image>>((localImages && safeJsonParse(localImages)) || []);
const [ loading, setLoading ] = useState(false); const [ loading, setLoading ] = useState(false);
useEffect(() => {
onOptionsChange({ ...initialOptions });
}, []);
const deleteStoredImage = useCallback(e => { const deleteStoredImage = useCallback(e => {
const imageId = e.currentTarget.getAttribute('data-imageid'); const imageId = e.currentTarget.getAttribute('data-imageid');
@ -377,7 +351,11 @@ function VirtualBackgrounds({
return acc; return acc;
}, {}) }, {})
}; };
const currentBackgroundLabel = labelsMap[selectedThumbnail] || labelsMap.none; const currentBackgroundLabel = options?.selectedThumbnail ? labelsMap[options.selectedThumbnail] : labelsMap.none;
const isThumbnailSelected = useCallback(thumbnail => options?.selectedThumbnail === thumbnail, [ options ]);
const getSelectedThumbnailClass = useCallback(
thumbnail => isThumbnailSelected(thumbnail) && classes.selectedThumbnail, [ isThumbnailSelected, options ]
);
return ( return (
<> <>
@ -415,10 +393,10 @@ function VirtualBackgrounds({
content = { t('virtualBackground.removeBackground') } content = { t('virtualBackground.removeBackground') }
position = { 'top' }> position = { 'top' }>
<div <div
aria-checked = { selectedThumbnail === 'none' } aria-checked = { isThumbnailSelected('none') }
aria-label = { t('virtualBackground.removeBackground') } aria-label = { t('virtualBackground.removeBackground') }
className = { cx(classes.thumbnail, classes.noneThumbnail, className = { cx(classes.thumbnail, classes.noneThumbnail,
selectedThumbnail === 'none' && classes.selectedThumbnail) } getSelectedThumbnailClass('none')) }
onClick = { removeBackground } onClick = { removeBackground }
onKeyPress = { removeBackgroundKeyPress } onKeyPress = { removeBackgroundKeyPress }
role = 'radio' role = 'radio'
@ -430,10 +408,10 @@ function VirtualBackgrounds({
content = { t('virtualBackground.slightBlur') } content = { t('virtualBackground.slightBlur') }
position = { 'top' }> position = { 'top' }>
<div <div
aria-checked = { selectedThumbnail === 'slight-blur' } aria-checked = { isThumbnailSelected('slight-blur') }
aria-label = { t('virtualBackground.slightBlur') } aria-label = { t('virtualBackground.slightBlur') }
className = { cx(classes.thumbnail, classes.slightBlur, className = { cx(classes.thumbnail, classes.slightBlur,
selectedThumbnail === 'slight-blur' && classes.selectedThumbnail) } getSelectedThumbnailClass('slight-blur')) }
onClick = { enableSlideBlur } onClick = { enableSlideBlur }
onKeyPress = { enableSlideBlurKeyPress } onKeyPress = { enableSlideBlurKeyPress }
role = 'radio' role = 'radio'
@ -445,10 +423,10 @@ function VirtualBackgrounds({
content = { t('virtualBackground.blur') } content = { t('virtualBackground.blur') }
position = { 'top' }> position = { 'top' }>
<div <div
aria-checked = { selectedThumbnail === 'blur' } aria-checked = { isThumbnailSelected('blur') }
aria-label = { t('virtualBackground.blur') } aria-label = { t('virtualBackground.blur') }
className = { cx(classes.thumbnail, classes.blur, className = { cx(classes.thumbnail, classes.blur,
selectedThumbnail === 'blur' && classes.selectedThumbnail) } getSelectedThumbnailClass('blur')) }
onClick = { enableBlur } onClick = { enableBlur }
onKeyPress = { enableBlurKeyPress } onKeyPress = { enableBlurKeyPress }
role = 'radio' role = 'radio'
@ -463,11 +441,9 @@ function VirtualBackgrounds({
position = { 'top' }> position = { 'top' }>
<img <img
alt = { image.tooltip && t(`virtualBackground.${image.tooltip}`) } alt = { image.tooltip && t(`virtualBackground.${image.tooltip}`) }
aria-checked = { options?.selectedThumbnail === image.id aria-checked = { isThumbnailSelected(image.id) }
|| selectedThumbnail === image.id }
className = { cx(classes.thumbnail, className = { cx(classes.thumbnail,
(options?.selectedThumbnail === image.id getSelectedThumbnailClass(image.id)) }
|| selectedThumbnail === image.id) && classes.selectedThumbnail) }
data-imageid = { image.id } data-imageid = { image.id }
onClick = { setImageBackground } onClick = { setImageBackground }
onError = { onError } onError = { onError }
@ -483,9 +459,9 @@ function VirtualBackgrounds({
key = { image.id }> key = { image.id }>
<img <img
alt = { t('virtualBackground.uploadedImage', { index: index + 1 }) } alt = { t('virtualBackground.uploadedImage', { index: index + 1 }) }
aria-checked = { selectedThumbnail === image.id } aria-checked = { isThumbnailSelected(image.id) }
className = { cx(classes.thumbnail, className = { cx(classes.thumbnail,
selectedThumbnail === image.id && classes.selectedThumbnail) } getSelectedThumbnailClass(image.id)) }
data-imageid = { image.id } data-imageid = { image.id }
onClick = { setUploadedImageBackground } onClick = { setUploadedImageBackground }
onError = { onError } onError = { onError }
@ -522,14 +498,11 @@ function VirtualBackgrounds({
* @returns {{Props}} * @returns {{Props}}
*/ */
function _mapStateToProps(state: IReduxState) { function _mapStateToProps(state: IReduxState) {
const { localFlipX } = state['features/base/settings'];
const dynamicBrandingImages = state['features/dynamic-branding'].virtualBackgrounds; const dynamicBrandingImages = state['features/dynamic-branding'].virtualBackgrounds;
const hasBrandingImages = Boolean(dynamicBrandingImages.length); const hasBrandingImages = Boolean(dynamicBrandingImages.length);
return { return {
_localFlipX: Boolean(localFlipX),
_images: (hasBrandingImages && dynamicBrandingImages) || IMAGES, _images: (hasBrandingImages && dynamicBrandingImages) || IMAGES,
_virtualBackground: state['features/virtual-background'],
_showUploadButton: !state['features/base/config'].disableAddingBackgroundImages, _showUploadButton: !state['features/base/config'].disableAddingBackgroundImages,
_multiStreamModeEnabled: getMultipleVideoSendingSupportFeatureFlag(state) _multiStreamModeEnabled: getMultipleVideoSendingSupportFeatureFlag(state)
}; };

Loading…
Cancel
Save