2021-02-18 15:52:47 +00:00
|
|
|
// @flow
|
2021-06-10 12:48:44 +00:00
|
|
|
|
2021-03-24 16:32:45 +00:00
|
|
|
import Spinner from '@atlaskit/spinner';
|
2021-06-02 19:21:39 +00:00
|
|
|
import Bourne from '@hapi/bourne';
|
2021-03-24 16:32:45 +00:00
|
|
|
import { jitsiLocalStorage } from '@jitsi/js-utils/jitsi-local-storage';
|
2021-09-10 07:00:54 +00:00
|
|
|
import React, { useState, useEffect, useCallback } from 'react';
|
2021-02-18 15:52:47 +00:00
|
|
|
|
2021-06-20 02:17:52 +00:00
|
|
|
import { Dialog, hideDialog, openDialog } from '../../base/dialog';
|
2021-02-18 15:52:47 +00:00
|
|
|
import { translate } from '../../base/i18n';
|
2021-09-10 07:00:54 +00:00
|
|
|
import { Icon, IconCloseSmall, IconShareDesktop } from '../../base/icons';
|
2021-06-20 02:17:52 +00:00
|
|
|
import { browser, JitsiTrackErrors } from '../../base/lib-jitsi-meet';
|
2021-05-14 14:53:11 +00:00
|
|
|
import { createLocalTrack } from '../../base/lib-jitsi-meet/functions';
|
2021-05-26 11:53:14 +00:00
|
|
|
import { VIDEO_TYPE } from '../../base/media';
|
2021-02-18 15:52:47 +00:00
|
|
|
import { connect } from '../../base/redux';
|
2021-06-24 15:21:34 +00:00
|
|
|
import { updateSettings } from '../../base/settings';
|
2021-06-10 12:48:44 +00:00
|
|
|
import { Tooltip } from '../../base/tooltip';
|
2021-05-06 06:54:23 +00:00
|
|
|
import { getLocalVideoTrack } from '../../base/tracks';
|
2021-05-26 16:01:00 +00:00
|
|
|
import { showErrorNotification } from '../../notifications';
|
2021-04-09 12:17:06 +00:00
|
|
|
import { toggleBackgroundEffect } from '../actions';
|
2021-09-10 07:00:54 +00:00
|
|
|
import { IMAGES, BACKGROUNDS_LIMIT, VIRTUAL_BACKGROUND_TYPE, type Image } from '../constants';
|
|
|
|
import { toDataURL } from '../functions';
|
2021-03-24 16:32:45 +00:00
|
|
|
import logger from '../logger';
|
2021-02-18 15:52:47 +00:00
|
|
|
|
2021-09-10 07:00:54 +00:00
|
|
|
import UploadImageButton from './UploadImageButton';
|
2021-05-06 06:54:23 +00:00
|
|
|
import VirtualBackgroundPreview from './VirtualBackgroundPreview';
|
|
|
|
|
2021-02-18 15:52:47 +00:00
|
|
|
type Props = {
|
|
|
|
|
2021-09-10 07:00:54 +00:00
|
|
|
/**
|
|
|
|
* The list of Images to choose from.
|
|
|
|
*/
|
|
|
|
_images: Array<Image>,
|
|
|
|
|
2021-06-24 15:21:34 +00:00
|
|
|
/**
|
|
|
|
* The current local flip x status.
|
|
|
|
*/
|
|
|
|
_localFlipX: boolean,
|
|
|
|
|
2021-05-06 06:54:23 +00:00
|
|
|
/**
|
|
|
|
* Returns the jitsi track that will have backgraund effect applied.
|
|
|
|
*/
|
|
|
|
_jitsiTrack: Object,
|
|
|
|
|
2021-04-09 14:25:26 +00:00
|
|
|
/**
|
|
|
|
* Returns the selected thumbnail identifier.
|
|
|
|
*/
|
|
|
|
_selectedThumbnail: string,
|
|
|
|
|
2021-09-10 07:00:54 +00:00
|
|
|
/**
|
|
|
|
* If the upload button should be displayed or not.
|
|
|
|
*/
|
|
|
|
_showUploadButton: boolean,
|
|
|
|
|
2021-05-19 09:57:11 +00:00
|
|
|
/**
|
2021-06-18 14:18:05 +00:00
|
|
|
* Returns the selected virtual background object.
|
2021-05-19 09:57:11 +00:00
|
|
|
*/
|
2021-06-18 14:18:05 +00:00
|
|
|
_virtualBackground: Object,
|
2021-05-19 09:57:11 +00:00
|
|
|
|
2021-02-18 15:52:47 +00:00
|
|
|
/**
|
|
|
|
* The redux {@code dispatch} function.
|
|
|
|
*/
|
|
|
|
dispatch: Function,
|
|
|
|
|
2021-06-20 02:17:52 +00:00
|
|
|
/**
|
|
|
|
* 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,
|
|
|
|
|
2021-02-18 15:52:47 +00:00
|
|
|
/**
|
|
|
|
* Invoked to obtain translated strings.
|
|
|
|
*/
|
|
|
|
t: Function
|
|
|
|
};
|
|
|
|
|
2021-06-10 12:48:44 +00:00
|
|
|
const onError = event => {
|
|
|
|
event.target.style.display = 'none';
|
|
|
|
};
|
|
|
|
|
2021-06-20 02:17:52 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Maps (parts of) the redux state to the associated props for the
|
|
|
|
* {@code VirtualBackground} component.
|
|
|
|
*
|
|
|
|
* @param {Object} state - The Redux state.
|
|
|
|
* @private
|
|
|
|
* @returns {{Props}}
|
|
|
|
*/
|
|
|
|
function _mapStateToProps(state): Object {
|
2021-06-24 15:21:34 +00:00
|
|
|
const { localFlipX } = state['features/base/settings'];
|
2021-09-10 07:00:54 +00:00
|
|
|
const dynamicBrandingImages = state['features/dynamic-branding'].virtualBackgrounds;
|
|
|
|
const hasBrandingImages = Boolean(dynamicBrandingImages.length);
|
2021-06-24 15:21:34 +00:00
|
|
|
|
2021-06-20 02:17:52 +00:00
|
|
|
return {
|
2021-06-24 15:21:34 +00:00
|
|
|
_localFlipX: Boolean(localFlipX),
|
2021-09-10 07:00:54 +00:00
|
|
|
_images: (hasBrandingImages && dynamicBrandingImages) || IMAGES,
|
2021-06-20 02:17:52 +00:00
|
|
|
_virtualBackground: state['features/virtual-background'],
|
|
|
|
_selectedThumbnail: state['features/virtual-background'].selectedThumbnail,
|
2021-09-10 07:00:54 +00:00
|
|
|
_showUploadButton: !(hasBrandingImages || state['features/base/config'].disableAddingBackgroundImages),
|
2021-06-20 02:17:52 +00:00
|
|
|
_jitsiTrack: getLocalVideoTrack(state['features/base/tracks'])?.jitsiTrack
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
const VirtualBackgroundDialog = translate(connect(_mapStateToProps)(VirtualBackground));
|
|
|
|
|
2021-02-18 15:52:47 +00:00
|
|
|
/**
|
|
|
|
* Renders virtual background dialog.
|
|
|
|
*
|
|
|
|
* @returns {ReactElement}
|
|
|
|
*/
|
2021-06-20 02:17:52 +00:00
|
|
|
function VirtualBackground({
|
2021-09-10 07:00:54 +00:00
|
|
|
_images,
|
2021-06-20 02:17:52 +00:00
|
|
|
_jitsiTrack,
|
2021-09-10 07:00:54 +00:00
|
|
|
_localFlipX,
|
2021-06-20 02:17:52 +00:00
|
|
|
_selectedThumbnail,
|
2021-09-10 07:00:54 +00:00
|
|
|
_showUploadButton,
|
2021-06-20 02:17:52 +00:00
|
|
|
_virtualBackground,
|
|
|
|
dispatch,
|
|
|
|
initialOptions,
|
|
|
|
t
|
|
|
|
}: Props) {
|
2021-08-26 13:33:43 +00:00
|
|
|
const [ previewIsLoaded, setPreviewIsLoaded ] = useState(false);
|
2021-06-20 02:17:52 +00:00
|
|
|
const [ options, setOptions ] = useState({ ...initialOptions });
|
2021-03-24 16:32:45 +00:00
|
|
|
const localImages = jitsiLocalStorage.getItem('virtualBackgrounds');
|
2021-06-10 12:48:44 +00:00
|
|
|
const [ storedImages, setStoredImages ] = useState<Array<Image>>((localImages && Bourne.parse(localImages)) || []);
|
|
|
|
const [ loading, setLoading ] = useState(false);
|
2021-09-10 07:00:54 +00:00
|
|
|
|
2021-06-18 14:18:05 +00:00
|
|
|
const [ activeDesktopVideo ] = useState(_virtualBackground?.virtualSource?.videoType === VIDEO_TYPE.DESKTOP
|
|
|
|
? _virtualBackground.virtualSource
|
|
|
|
: null);
|
|
|
|
const [ initialVirtualBackground ] = useState(_virtualBackground);
|
2021-06-10 12:48:44 +00:00
|
|
|
const deleteStoredImage = useCallback(e => {
|
|
|
|
const imageId = e.currentTarget.getAttribute('data-imageid');
|
|
|
|
|
|
|
|
setStoredImages(storedImages.filter(item => item.id !== imageId));
|
|
|
|
}, [ storedImages ]);
|
|
|
|
|
|
|
|
const deleteStoredImageKeyPress = useCallback(e => {
|
|
|
|
if (e.key === ' ' || e.key === 'Enter') {
|
|
|
|
e.preventDefault();
|
|
|
|
deleteStoredImage(e);
|
|
|
|
}
|
|
|
|
}, [ deleteStoredImage ]);
|
2021-03-24 16:32:45 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Updates stored images on local storage.
|
|
|
|
*/
|
|
|
|
useEffect(() => {
|
2021-04-09 12:17:06 +00:00
|
|
|
try {
|
|
|
|
jitsiLocalStorage.setItem('virtualBackgrounds', JSON.stringify(storedImages));
|
|
|
|
} catch (err) {
|
|
|
|
// Preventing localStorage QUOTA_EXCEEDED_ERR
|
2021-06-10 12:48:44 +00:00
|
|
|
err && setStoredImages(storedImages.slice(1));
|
2021-04-09 12:17:06 +00:00
|
|
|
}
|
2021-09-10 07:00:54 +00:00
|
|
|
if (storedImages.length === BACKGROUNDS_LIMIT) {
|
2021-06-10 12:48:44 +00:00
|
|
|
setStoredImages(storedImages.slice(1));
|
2021-03-24 16:32:45 +00:00
|
|
|
}
|
2021-07-08 17:20:12 +00:00
|
|
|
}, [ storedImages ]);
|
2021-03-24 16:32:45 +00:00
|
|
|
|
2021-06-10 12:48:44 +00:00
|
|
|
const enableBlur = useCallback(async () => {
|
2021-05-06 06:54:23 +00:00
|
|
|
setOptions({
|
2021-05-26 11:53:14 +00:00
|
|
|
backgroundType: VIRTUAL_BACKGROUND_TYPE.BLUR,
|
2021-05-06 06:54:23 +00:00
|
|
|
enabled: true,
|
2021-06-10 12:48:44 +00:00
|
|
|
blurValue: 25,
|
|
|
|
selectedThumbnail: 'blur'
|
2021-05-06 06:54:23 +00:00
|
|
|
});
|
2021-07-14 15:23:40 +00:00
|
|
|
logger.info('"Blur" option setted for virtual background preview!');
|
|
|
|
|
2021-06-10 12:48:44 +00:00
|
|
|
}, []);
|
2021-02-18 15:52:47 +00:00
|
|
|
|
2021-06-10 12:48:44 +00:00
|
|
|
const enableBlurKeyPress = useCallback(e => {
|
|
|
|
if (e.key === ' ' || e.key === 'Enter') {
|
|
|
|
e.preventDefault();
|
|
|
|
enableBlur();
|
|
|
|
}
|
|
|
|
}, [ enableBlur ]);
|
|
|
|
|
|
|
|
const enableSlideBlur = useCallback(async () => {
|
2021-05-06 06:54:23 +00:00
|
|
|
setOptions({
|
2021-06-10 12:48:44 +00:00
|
|
|
backgroundType: VIRTUAL_BACKGROUND_TYPE.BLUR,
|
|
|
|
enabled: true,
|
|
|
|
blurValue: 8,
|
|
|
|
selectedThumbnail: 'slight-blur'
|
2021-05-06 06:54:23 +00:00
|
|
|
});
|
2021-07-14 15:23:40 +00:00
|
|
|
logger.info('"Slight-blur" option setted for virtual background preview!');
|
|
|
|
|
2021-06-10 12:48:44 +00:00
|
|
|
}, []);
|
|
|
|
|
|
|
|
const enableSlideBlurKeyPress = useCallback(e => {
|
|
|
|
if (e.key === ' ' || e.key === 'Enter') {
|
|
|
|
e.preventDefault();
|
|
|
|
enableSlideBlur();
|
|
|
|
}
|
|
|
|
}, [ enableSlideBlur ]);
|
2021-03-24 16:32:45 +00:00
|
|
|
|
2021-06-10 12:48:44 +00:00
|
|
|
|
|
|
|
const shareDesktop = useCallback(async () => {
|
2021-06-20 02:17:52 +00:00
|
|
|
let isCancelled = false, url;
|
|
|
|
|
|
|
|
try {
|
|
|
|
url = await createLocalTrack('desktop', '');
|
|
|
|
} catch (e) {
|
|
|
|
if (e.name === JitsiTrackErrors.SCREENSHARING_USER_CANCELED) {
|
|
|
|
isCancelled = true;
|
|
|
|
} else {
|
|
|
|
logger.error(e);
|
|
|
|
}
|
|
|
|
}
|
2021-05-14 14:53:11 +00:00
|
|
|
|
2021-05-26 11:53:14 +00:00
|
|
|
if (!url) {
|
2021-06-20 02:17:52 +00:00
|
|
|
if (!isCancelled) {
|
|
|
|
dispatch(showErrorNotification({
|
|
|
|
titleKey: 'virtualBackground.desktopShareError'
|
|
|
|
}));
|
|
|
|
logger.error('Could not create desktop share as a virtual background!');
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* For electron createLocalTrack will open the {@code DesktopPicker} dialog and hide the
|
|
|
|
* {@code VirtualBackgroundDialog}. That's why we need to reopen the {@code VirtualBackgroundDialog}
|
|
|
|
* and restore the current state through {@code initialOptions} prop.
|
|
|
|
*/
|
|
|
|
if (browser.isElectron()) {
|
|
|
|
dispatch(openDialog(VirtualBackgroundDialog, { initialOptions: options }));
|
|
|
|
}
|
2021-05-26 16:01:00 +00:00
|
|
|
|
|
|
|
return;
|
2021-05-26 11:53:14 +00:00
|
|
|
}
|
2021-06-20 02:17:52 +00:00
|
|
|
|
|
|
|
const newOptions = {
|
2021-05-26 11:53:14 +00:00
|
|
|
backgroundType: VIRTUAL_BACKGROUND_TYPE.DESKTOP_SHARE,
|
2021-05-13 14:38:23 +00:00
|
|
|
enabled: true,
|
2021-06-10 12:48:44 +00:00
|
|
|
selectedThumbnail: 'desktop-share',
|
2021-05-14 14:53:11 +00:00
|
|
|
url
|
2021-06-20 02:17:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* For electron createLocalTrack will open the {@code DesktopPicker} dialog and hide the
|
|
|
|
* {@code VirtualBackgroundDialog}. That's why we need to reopen the {@code VirtualBackgroundDialog}
|
|
|
|
* and force it to show desktop share virtual background through {@code initialOptions} prop.
|
|
|
|
*/
|
|
|
|
if (browser.isElectron()) {
|
|
|
|
dispatch(openDialog(VirtualBackgroundDialog, { initialOptions: newOptions }));
|
|
|
|
} else {
|
|
|
|
setOptions(newOptions);
|
2021-07-14 15:23:40 +00:00
|
|
|
logger.info('"Desktop-share" option setted for virtual background preview!');
|
2021-06-20 02:17:52 +00:00
|
|
|
}
|
|
|
|
}, [ dispatch, options ]);
|
2021-06-10 12:48:44 +00:00
|
|
|
|
|
|
|
const shareDesktopKeyPress = useCallback(e => {
|
|
|
|
if (e.key === ' ' || e.key === 'Enter') {
|
|
|
|
e.preventDefault();
|
|
|
|
shareDesktop();
|
|
|
|
}
|
|
|
|
}, [ shareDesktop ]);
|
2021-05-13 14:38:23 +00:00
|
|
|
|
2021-06-10 12:48:44 +00:00
|
|
|
const removeBackground = useCallback(async () => {
|
2021-05-06 06:54:23 +00:00
|
|
|
setOptions({
|
2021-06-10 12:48:44 +00:00
|
|
|
enabled: false,
|
|
|
|
selectedThumbnail: 'none'
|
2021-05-06 06:54:23 +00:00
|
|
|
});
|
2021-07-14 15:23:40 +00:00
|
|
|
logger.info('"None" option setted for virtual background preview!');
|
|
|
|
|
2021-06-10 12:48:44 +00:00
|
|
|
}, []);
|
2021-02-18 15:52:47 +00:00
|
|
|
|
2021-06-10 12:48:44 +00:00
|
|
|
const removeBackgroundKeyPress = useCallback(e => {
|
|
|
|
if (e.key === ' ' || e.key === 'Enter') {
|
|
|
|
e.preventDefault();
|
|
|
|
removeBackground();
|
|
|
|
}
|
|
|
|
}, [ removeBackground ]);
|
2021-04-09 12:17:06 +00:00
|
|
|
|
2021-06-10 12:48:44 +00:00
|
|
|
const setUploadedImageBackground = useCallback(async e => {
|
|
|
|
const imageId = e.currentTarget.getAttribute('data-imageid');
|
|
|
|
const image = storedImages.find(img => img.id === imageId);
|
|
|
|
|
|
|
|
if (image) {
|
|
|
|
setOptions({
|
|
|
|
backgroundType: 'image',
|
|
|
|
enabled: true,
|
|
|
|
url: image.src,
|
|
|
|
selectedThumbnail: image.id
|
|
|
|
});
|
2021-07-14 15:23:40 +00:00
|
|
|
logger.info('Uploaded image setted for virtual background preview!');
|
2021-06-10 12:48:44 +00:00
|
|
|
}
|
|
|
|
}, [ storedImages ]);
|
|
|
|
|
|
|
|
const setImageBackground = useCallback(async e => {
|
|
|
|
const imageId = e.currentTarget.getAttribute('data-imageid');
|
2021-09-10 07:00:54 +00:00
|
|
|
const image = _images.find(img => img.id === imageId);
|
2021-06-10 12:48:44 +00:00
|
|
|
|
|
|
|
if (image) {
|
2021-09-10 07:00:54 +00:00
|
|
|
try {
|
|
|
|
const url = await toDataURL(image.src);
|
|
|
|
|
|
|
|
setOptions({
|
|
|
|
backgroundType: 'image',
|
|
|
|
enabled: true,
|
|
|
|
url,
|
|
|
|
selectedThumbnail: image.id
|
|
|
|
});
|
|
|
|
logger.info('Image set for virtual background preview!');
|
|
|
|
} catch (err) {
|
|
|
|
logger.error('Could not fetch virtual background image:', err);
|
|
|
|
}
|
2021-07-14 15:23:40 +00:00
|
|
|
|
2021-06-10 12:48:44 +00:00
|
|
|
setLoading(false);
|
|
|
|
}
|
|
|
|
}, []);
|
|
|
|
|
|
|
|
const setImageBackgroundKeyPress = useCallback(e => {
|
|
|
|
if (e.key === ' ' || e.key === 'Enter') {
|
|
|
|
e.preventDefault();
|
|
|
|
setImageBackground(e);
|
|
|
|
}
|
|
|
|
}, [ setImageBackground ]);
|
|
|
|
|
|
|
|
const setUploadedImageBackgroundKeyPress = useCallback(e => {
|
|
|
|
if (e.key === ' ' || e.key === 'Enter') {
|
|
|
|
e.preventDefault();
|
|
|
|
setUploadedImageBackground(e);
|
|
|
|
}
|
|
|
|
}, [ setUploadedImageBackground ]);
|
2021-02-18 15:52:47 +00:00
|
|
|
|
2021-06-10 12:48:44 +00:00
|
|
|
const applyVirtualBackground = useCallback(async () => {
|
2021-05-19 09:57:11 +00:00
|
|
|
if (activeDesktopVideo) {
|
|
|
|
await activeDesktopVideo.dispose();
|
|
|
|
}
|
2021-06-10 12:48:44 +00:00
|
|
|
setLoading(true);
|
2021-05-06 06:54:23 +00:00
|
|
|
await dispatch(toggleBackgroundEffect(options, _jitsiTrack));
|
2021-06-10 12:48:44 +00:00
|
|
|
await setLoading(false);
|
2021-07-08 17:20:12 +00:00
|
|
|
if (_localFlipX && options.backgroundType === VIRTUAL_BACKGROUND_TYPE.DESKTOP_SHARE) {
|
|
|
|
dispatch(updateSettings({
|
|
|
|
localFlipX: !_localFlipX
|
|
|
|
}));
|
2021-07-12 11:28:11 +00:00
|
|
|
} else {
|
|
|
|
|
|
|
|
// Set x scale to default value.
|
|
|
|
dispatch(updateSettings({
|
|
|
|
localFlipX: true
|
|
|
|
}));
|
2021-07-08 17:20:12 +00:00
|
|
|
}
|
2021-05-06 06:54:23 +00:00
|
|
|
dispatch(hideDialog());
|
2021-07-14 15:23:40 +00:00
|
|
|
logger.info(`Virtual background type: '${typeof options.backgroundType === 'undefined'
|
|
|
|
? 'none' : options.backgroundType}' applied!`);
|
2021-07-08 17:20:12 +00:00
|
|
|
}, [ dispatch, options, _localFlipX ]);
|
2021-05-06 06:54:23 +00:00
|
|
|
|
2021-06-18 14:18:05 +00:00
|
|
|
// Prevent the selection of a new virtual background if it has not been applied by default
|
|
|
|
const cancelVirtualBackground = useCallback(async () => {
|
|
|
|
await setOptions({
|
|
|
|
backgroundType: initialVirtualBackground.backgroundType,
|
|
|
|
enabled: initialVirtualBackground.backgroundEffectEnabled,
|
|
|
|
url: initialVirtualBackground.virtualSource,
|
|
|
|
selectedThumbnail: initialVirtualBackground.selectedThumbnail,
|
|
|
|
blurValue: initialVirtualBackground.blurValue
|
|
|
|
});
|
|
|
|
dispatch(hideDialog());
|
|
|
|
});
|
|
|
|
|
2021-08-26 13:33:43 +00:00
|
|
|
const loadedPreviewState = useCallback(async loaded => {
|
|
|
|
await setPreviewIsLoaded(loaded);
|
|
|
|
});
|
|
|
|
|
2021-02-18 15:52:47 +00:00
|
|
|
return (
|
|
|
|
<Dialog
|
2021-05-06 06:54:23 +00:00
|
|
|
hideCancelButton = { false }
|
|
|
|
okKey = { 'virtualBackground.apply' }
|
2021-06-18 14:18:05 +00:00
|
|
|
onCancel = { cancelVirtualBackground }
|
2021-05-06 06:54:23 +00:00
|
|
|
onSubmit = { applyVirtualBackground }
|
2021-08-26 13:33:43 +00:00
|
|
|
submitDisabled = { !options || loading || !previewIsLoaded }
|
2021-05-20 15:12:39 +00:00
|
|
|
titleKey = { 'virtualBackground.title' } >
|
2021-08-26 13:33:43 +00:00
|
|
|
<VirtualBackgroundPreview
|
|
|
|
loadedPreview = { loadedPreviewState }
|
|
|
|
options = { options } />
|
2021-03-24 16:32:45 +00:00
|
|
|
{loading ? (
|
2021-03-25 12:52:53 +00:00
|
|
|
<div className = 'virtual-background-loading'>
|
2021-03-24 16:32:45 +00:00
|
|
|
<Spinner
|
|
|
|
isCompleting = { false }
|
|
|
|
size = 'medium' />
|
|
|
|
</div>
|
|
|
|
) : (
|
|
|
|
<div>
|
2021-09-10 07:00:54 +00:00
|
|
|
{_showUploadButton
|
|
|
|
&& <UploadImageButton
|
|
|
|
setLoading = { setLoading }
|
|
|
|
setOptions = { setOptions }
|
|
|
|
setStoredImages = { setStoredImages }
|
|
|
|
showLabel = { previewIsLoaded }
|
|
|
|
storedImages = { storedImages } />}
|
2021-06-10 12:48:44 +00:00
|
|
|
<div
|
|
|
|
className = 'virtual-background-dialog'
|
|
|
|
role = 'radiogroup'
|
|
|
|
tabIndex = '-1'>
|
|
|
|
<Tooltip
|
|
|
|
content = { t('virtualBackground.removeBackground') }
|
|
|
|
position = { 'top' }>
|
|
|
|
<div
|
|
|
|
aria-checked = { _selectedThumbnail === 'none' }
|
|
|
|
aria-label = { t('virtualBackground.removeBackground') }
|
|
|
|
className = { _selectedThumbnail === 'none' ? 'background-option none-selected'
|
|
|
|
: 'background-option virtual-background-none' }
|
|
|
|
onClick = { removeBackground }
|
|
|
|
onKeyPress = { removeBackgroundKeyPress }
|
|
|
|
role = 'radio'
|
|
|
|
tabIndex = { 0 } >
|
|
|
|
{t('virtualBackground.none')}
|
|
|
|
</div>
|
|
|
|
</Tooltip>
|
|
|
|
<Tooltip
|
|
|
|
content = { t('virtualBackground.slightBlur') }
|
|
|
|
position = { 'top' }>
|
|
|
|
<div
|
|
|
|
aria-checked = { _selectedThumbnail === 'slight-blur' }
|
|
|
|
aria-label = { t('virtualBackground.slightBlur') }
|
|
|
|
className = { _selectedThumbnail === 'slight-blur'
|
|
|
|
? 'background-option slight-blur-selected' : 'background-option slight-blur' }
|
|
|
|
onClick = { enableSlideBlur }
|
|
|
|
onKeyPress = { enableSlideBlurKeyPress }
|
|
|
|
role = 'radio'
|
|
|
|
tabIndex = { 0 }>
|
|
|
|
{t('virtualBackground.slightBlur')}
|
|
|
|
</div>
|
|
|
|
</Tooltip>
|
|
|
|
<Tooltip
|
|
|
|
content = { t('virtualBackground.blur') }
|
|
|
|
position = { 'top' }>
|
|
|
|
<div
|
|
|
|
aria-checked = { _selectedThumbnail === 'blur' }
|
|
|
|
aria-label = { t('virtualBackground.blur') }
|
|
|
|
className = { _selectedThumbnail === 'blur' ? 'background-option blur-selected'
|
|
|
|
: 'background-option blur' }
|
|
|
|
onClick = { enableBlur }
|
|
|
|
onKeyPress = { enableBlurKeyPress }
|
|
|
|
role = 'radio'
|
|
|
|
tabIndex = { 0 }>
|
|
|
|
{t('virtualBackground.blur')}
|
|
|
|
</div>
|
|
|
|
</Tooltip>
|
|
|
|
<Tooltip
|
|
|
|
content = { t('virtualBackground.desktopShare') }
|
|
|
|
position = { 'top' }>
|
|
|
|
<div
|
|
|
|
aria-checked = { _selectedThumbnail === 'desktop-share' }
|
|
|
|
aria-label = { t('virtualBackground.desktopShare') }
|
|
|
|
className = { _selectedThumbnail === 'desktop-share'
|
|
|
|
? 'background-option desktop-share-selected'
|
|
|
|
: 'background-option desktop-share' }
|
|
|
|
onClick = { shareDesktop }
|
|
|
|
onKeyPress = { shareDesktopKeyPress }
|
|
|
|
role = 'radio'
|
|
|
|
tabIndex = { 0 }>
|
|
|
|
<Icon
|
|
|
|
className = 'share-desktop-icon'
|
|
|
|
size = { 30 }
|
|
|
|
src = { IconShareDesktop } />
|
|
|
|
</div>
|
|
|
|
</Tooltip>
|
2021-09-10 07:00:54 +00:00
|
|
|
{_images.map(image => (
|
2021-06-10 12:48:44 +00:00
|
|
|
<Tooltip
|
|
|
|
content = { image.tooltip && t(`virtualBackground.${image.tooltip}`) }
|
|
|
|
key = { image.id }
|
|
|
|
position = { 'top' }>
|
|
|
|
<img
|
|
|
|
alt = { image.tooltip && t(`virtualBackground.${image.tooltip}`) }
|
|
|
|
aria-checked = { options.selectedThumbnail === image.id
|
|
|
|
|| _selectedThumbnail === image.id }
|
|
|
|
className = {
|
|
|
|
options.selectedThumbnail === image.id || _selectedThumbnail === image.id
|
|
|
|
? 'background-option thumbnail-selected' : 'background-option thumbnail' }
|
|
|
|
data-imageid = { image.id }
|
|
|
|
onClick = { setImageBackground }
|
|
|
|
onError = { onError }
|
|
|
|
onKeyPress = { setImageBackgroundKeyPress }
|
|
|
|
role = 'radio'
|
|
|
|
src = { image.src }
|
|
|
|
tabIndex = { 0 } />
|
|
|
|
</Tooltip>
|
2021-03-24 16:32:45 +00:00
|
|
|
))}
|
|
|
|
{storedImages.map((image, index) => (
|
|
|
|
<div
|
|
|
|
className = { 'thumbnail-container' }
|
2021-06-10 12:48:44 +00:00
|
|
|
key = { image.id }>
|
2021-03-24 16:32:45 +00:00
|
|
|
<img
|
2021-06-10 12:48:44 +00:00
|
|
|
alt = { t('virtualBackground.uploadedImage', { index: index + 1 }) }
|
|
|
|
aria-checked = { _selectedThumbnail === image.id }
|
|
|
|
className = { _selectedThumbnail === image.id
|
|
|
|
? 'background-option thumbnail-selected' : 'background-option thumbnail' }
|
|
|
|
data-imageid = { image.id }
|
|
|
|
onClick = { setUploadedImageBackground }
|
|
|
|
onError = { onError }
|
|
|
|
onKeyPress = { setUploadedImageBackgroundKeyPress }
|
|
|
|
role = 'radio'
|
|
|
|
src = { image.src }
|
|
|
|
tabIndex = { 0 } />
|
|
|
|
|
2021-03-24 16:32:45 +00:00
|
|
|
<Icon
|
2021-06-10 12:48:44 +00:00
|
|
|
ariaLabel = { t('virtualBackground.deleteImage') }
|
2021-03-24 16:32:45 +00:00
|
|
|
className = { 'delete-image-icon' }
|
2021-06-10 12:48:44 +00:00
|
|
|
data-imageid = { image.id }
|
|
|
|
onClick = { deleteStoredImage }
|
|
|
|
onKeyPress = { deleteStoredImageKeyPress }
|
|
|
|
role = 'button'
|
2021-03-24 16:32:45 +00:00
|
|
|
size = { 15 }
|
2021-06-10 12:48:44 +00:00
|
|
|
src = { IconCloseSmall }
|
|
|
|
tabIndex = { 0 } />
|
2021-03-24 16:32:45 +00:00
|
|
|
</div>
|
|
|
|
))}
|
2021-02-18 15:52:47 +00:00
|
|
|
</div>
|
2021-03-24 16:32:45 +00:00
|
|
|
</div>
|
|
|
|
)}
|
2021-02-18 15:52:47 +00:00
|
|
|
</Dialog>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2021-06-20 02:17:52 +00:00
|
|
|
export default VirtualBackgroundDialog;
|