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-06-10 12:48:44 +00:00
|
|
|
import React, { useState, useEffect, useCallback, useRef } from 'react';
|
2021-03-24 16:32:45 +00:00
|
|
|
import uuid from 'uuid';
|
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-05-13 14:38:23 +00:00
|
|
|
import { Icon, IconCloseSmall, IconPlusCircle, 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-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-05-26 11:53:14 +00:00
|
|
|
import { VIRTUAL_BACKGROUND_TYPE } from '../constants';
|
2021-03-24 16:32:45 +00:00
|
|
|
import { resizeImage, toDataURL } from '../functions';
|
|
|
|
import logger from '../logger';
|
2021-02-18 15:52:47 +00:00
|
|
|
|
2021-05-06 06:54:23 +00:00
|
|
|
import VirtualBackgroundPreview from './VirtualBackgroundPreview';
|
|
|
|
|
2021-06-10 12:48:44 +00:00
|
|
|
|
|
|
|
type Image = {
|
|
|
|
tooltip?: string,
|
|
|
|
id: string,
|
|
|
|
src: string
|
|
|
|
}
|
|
|
|
|
2021-04-09 12:17:06 +00:00
|
|
|
// The limit of virtual background uploads is 24. When the number
|
|
|
|
// of uploads is 25 we trigger the deleteStoredImage function to delete
|
2021-03-24 16:32:45 +00:00
|
|
|
// the first/oldest uploaded background.
|
2021-04-09 12:17:06 +00:00
|
|
|
const backgroundsLimit = 25;
|
2021-06-10 12:48:44 +00:00
|
|
|
const images: Array<Image> = [
|
2021-02-18 15:52:47 +00:00
|
|
|
{
|
2021-06-10 12:48:44 +00:00
|
|
|
tooltip: 'image1',
|
2021-04-09 14:25:26 +00:00
|
|
|
id: '1',
|
2021-02-18 15:52:47 +00:00
|
|
|
src: 'images/virtual-background/background-1.jpg'
|
|
|
|
},
|
|
|
|
{
|
2021-06-10 12:48:44 +00:00
|
|
|
tooltip: 'image2',
|
2021-04-09 14:25:26 +00:00
|
|
|
id: '2',
|
2021-02-18 15:52:47 +00:00
|
|
|
src: 'images/virtual-background/background-2.jpg'
|
|
|
|
},
|
|
|
|
{
|
2021-06-10 12:48:44 +00:00
|
|
|
tooltip: 'image3',
|
2021-04-09 14:25:26 +00:00
|
|
|
id: '3',
|
2021-02-18 15:52:47 +00:00
|
|
|
src: 'images/virtual-background/background-3.jpg'
|
|
|
|
},
|
|
|
|
{
|
2021-06-10 12:48:44 +00:00
|
|
|
tooltip: 'image4',
|
2021-04-09 14:25:26 +00:00
|
|
|
id: '4',
|
2021-02-18 15:52:47 +00:00
|
|
|
src: 'images/virtual-background/background-4.jpg'
|
2021-04-14 16:26:36 +00:00
|
|
|
},
|
|
|
|
{
|
2021-06-10 12:48:44 +00:00
|
|
|
tooltip: 'image5',
|
2021-04-14 16:26:36 +00:00
|
|
|
id: '5',
|
|
|
|
src: 'images/virtual-background/background-5.jpg'
|
|
|
|
},
|
|
|
|
{
|
2021-06-10 12:48:44 +00:00
|
|
|
tooltip: 'image6',
|
2021-04-14 16:26:36 +00:00
|
|
|
id: '6',
|
|
|
|
src: 'images/virtual-background/background-6.jpg'
|
|
|
|
},
|
|
|
|
{
|
2021-06-10 12:48:44 +00:00
|
|
|
tooltip: 'image7',
|
2021-04-14 16:26:36 +00:00
|
|
|
id: '7',
|
|
|
|
src: 'images/virtual-background/background-7.jpg'
|
2021-02-18 15:52:47 +00:00
|
|
|
}
|
|
|
|
];
|
|
|
|
type Props = {
|
|
|
|
|
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-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 {
|
|
|
|
return {
|
|
|
|
_virtualBackground: state['features/virtual-background'],
|
|
|
|
_selectedThumbnail: state['features/virtual-background'].selectedThumbnail,
|
|
|
|
_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({
|
|
|
|
_jitsiTrack,
|
|
|
|
_selectedThumbnail,
|
|
|
|
_virtualBackground,
|
|
|
|
dispatch,
|
|
|
|
initialOptions,
|
|
|
|
t
|
|
|
|
}: Props) {
|
|
|
|
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);
|
|
|
|
const uploadImageButton: Object = useRef(null);
|
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-03-24 16:32:45 +00:00
|
|
|
if (storedImages.length === backgroundsLimit) {
|
2021-06-10 12:48:44 +00:00
|
|
|
setStoredImages(storedImages.slice(1));
|
2021-03-24 16:32:45 +00:00
|
|
|
}
|
|
|
|
}, [ storedImages ]);
|
|
|
|
|
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-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-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);
|
|
|
|
}
|
|
|
|
}, [ 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-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
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}, [ storedImages ]);
|
|
|
|
|
|
|
|
const setImageBackground = useCallback(async e => {
|
|
|
|
const imageId = e.currentTarget.getAttribute('data-imageid');
|
|
|
|
const image = images.find(img => img.id === imageId);
|
|
|
|
|
|
|
|
if (image) {
|
|
|
|
const url = await toDataURL(image.src);
|
2021-03-24 16:32:45 +00:00
|
|
|
|
2021-06-10 12:48:44 +00:00
|
|
|
setOptions({
|
|
|
|
backgroundType: 'image',
|
|
|
|
enabled: true,
|
|
|
|
url,
|
|
|
|
selectedThumbnail: image.id
|
|
|
|
});
|
|
|
|
setLoading(false);
|
|
|
|
}
|
|
|
|
}, []);
|
|
|
|
|
|
|
|
const uploadImage = useCallback(async e => {
|
2021-03-24 16:32:45 +00:00
|
|
|
const reader = new FileReader();
|
2021-06-10 12:48:44 +00:00
|
|
|
const imageFile = e.target.files;
|
2021-03-24 16:32:45 +00:00
|
|
|
|
|
|
|
reader.readAsDataURL(imageFile[0]);
|
|
|
|
reader.onload = async () => {
|
2021-04-09 12:17:06 +00:00
|
|
|
const url = await resizeImage(reader.result);
|
2021-04-09 14:25:26 +00:00
|
|
|
const uuId = uuid.v4();
|
2021-03-24 16:32:45 +00:00
|
|
|
|
|
|
|
setStoredImages([
|
|
|
|
...storedImages,
|
|
|
|
{
|
2021-04-09 14:25:26 +00:00
|
|
|
id: uuId,
|
2021-04-09 12:17:06 +00:00
|
|
|
src: url
|
2021-03-24 16:32:45 +00:00
|
|
|
}
|
|
|
|
]);
|
2021-05-06 06:54:23 +00:00
|
|
|
setOptions({
|
2021-05-26 11:53:14 +00:00
|
|
|
backgroundType: VIRTUAL_BACKGROUND_TYPE.IMAGE,
|
2021-05-06 06:54:23 +00:00
|
|
|
enabled: true,
|
|
|
|
url,
|
|
|
|
selectedThumbnail: uuId
|
|
|
|
});
|
2021-03-24 16:32:45 +00:00
|
|
|
};
|
|
|
|
reader.onerror = () => {
|
2021-06-10 12:48:44 +00:00
|
|
|
setLoading(false);
|
2021-03-24 16:32:45 +00:00
|
|
|
logger.error('Failed to upload virtual image!');
|
|
|
|
};
|
2021-06-10 12:48:44 +00:00
|
|
|
}, [ dispatch, storedImages ]);
|
|
|
|
|
|
|
|
const uploadImageKeyPress = useCallback(e => {
|
|
|
|
if (uploadImageButton.current && (e.key === ' ' || e.key === 'Enter')) {
|
|
|
|
e.preventDefault();
|
|
|
|
uploadImageButton.current.click();
|
|
|
|
}
|
|
|
|
}, [ uploadImageButton.current ]);
|
|
|
|
|
|
|
|
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-05-06 06:54:23 +00:00
|
|
|
dispatch(hideDialog());
|
2021-06-10 12:48:44 +00:00
|
|
|
}, [ dispatch, options ]);
|
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-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 }
|
|
|
|
submitDisabled = { !options || loading }
|
2021-05-20 15:12:39 +00:00
|
|
|
titleKey = { 'virtualBackground.title' } >
|
2021-05-06 06:54:23 +00:00
|
|
|
<VirtualBackgroundPreview 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-04-14 16:26:36 +00:00
|
|
|
<label
|
2021-06-10 12:48:44 +00:00
|
|
|
aria-label = { t('virtualBackground.uploadImage') }
|
2021-04-14 16:26:36 +00:00
|
|
|
className = 'file-upload-label'
|
2021-06-10 12:48:44 +00:00
|
|
|
htmlFor = 'file-upload'
|
|
|
|
onKeyPress = { uploadImageKeyPress }
|
|
|
|
tabIndex = { 0 } >
|
2021-04-14 16:26:36 +00:00
|
|
|
<Icon
|
|
|
|
className = { 'add-background' }
|
|
|
|
size = { 20 }
|
|
|
|
src = { IconPlusCircle } />
|
|
|
|
{t('virtualBackground.addBackground')}
|
|
|
|
</label>
|
|
|
|
<input
|
|
|
|
accept = 'image/*'
|
|
|
|
className = 'file-upload-btn'
|
|
|
|
id = 'file-upload'
|
2021-06-10 12:48:44 +00:00
|
|
|
onChange = { uploadImage }
|
|
|
|
ref = { uploadImageButton }
|
2021-04-14 16:26:36 +00:00
|
|
|
type = 'file' />
|
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>
|
|
|
|
{images.map(image => (
|
|
|
|
<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;
|