Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

VirtualBackgroundDialog.tsx 27KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708
  1. /* eslint-disable lines-around-comment */
  2. import Spinner from '@atlaskit/spinner';
  3. // @ts-ignore
  4. import Bourne from '@hapi/bourne';
  5. // @ts-ignore
  6. import { jitsiLocalStorage } from '@jitsi/js-utils/jitsi-local-storage';
  7. import { makeStyles } from '@material-ui/styles';
  8. import clsx from 'clsx';
  9. import React, { useState, useEffect, useCallback } from 'react';
  10. import { WithTranslation } from 'react-i18next';
  11. import { useSelector } from 'react-redux';
  12. import { IState } from '../../app/types';
  13. // @ts-ignore
  14. import { getMultipleVideoSendingSupportFeatureFlag } from '../../base/config';
  15. // @ts-ignore
  16. import { Dialog, hideDialog, openDialog } from '../../base/dialog';
  17. import { translate } from '../../base/i18n/functions';
  18. import Icon from '../../base/icons/components/Icon';
  19. import { IconCloseSmall, IconShareDesktop } from '../../base/icons/svg/index';
  20. import { browser, JitsiTrackErrors } from '../../base/lib-jitsi-meet';
  21. // @ts-ignore
  22. import { createLocalTrack } from '../../base/lib-jitsi-meet/functions';
  23. import { VIDEO_TYPE } from '../../base/media/constants';
  24. import { connect } from '../../base/redux/functions';
  25. // @ts-ignore
  26. import { updateSettings } from '../../base/settings';
  27. // @ts-ignore
  28. import { Tooltip } from '../../base/tooltip';
  29. // @ts-ignore
  30. import { getLocalVideoTrack } from '../../base/tracks';
  31. // @ts-ignore
  32. import { NOTIFICATION_TIMEOUT_TYPE, showErrorNotification } from '../../notifications';
  33. // @ts-ignore
  34. import { toggleBackgroundEffect, virtualBackgroundTrackChanged } from '../actions';
  35. import { IMAGES, BACKGROUNDS_LIMIT, VIRTUAL_BACKGROUND_TYPE, type Image } from '../constants';
  36. // @ts-ignore
  37. import { toDataURL } from '../functions';
  38. // @ts-ignore
  39. import logger from '../logger';
  40. import UploadImageButton from './UploadImageButton';
  41. // @ts-ignore
  42. import VirtualBackgroundPreview from './VirtualBackgroundPreview';
  43. interface Props extends WithTranslation {
  44. /**
  45. * The list of Images to choose from.
  46. */
  47. _images: Array<Image>,
  48. /**
  49. * Returns the jitsi track that will have backgraund effect applied.
  50. */
  51. _jitsiTrack: Object,
  52. /**
  53. * The current local flip x status.
  54. */
  55. _localFlipX: boolean,
  56. /**
  57. * Whether or not multi-stream send support is enabled.
  58. */
  59. _multiStreamModeEnabled: boolean,
  60. /**
  61. * Returns the selected thumbnail identifier.
  62. */
  63. _selectedThumbnail: string,
  64. /**
  65. * If the upload button should be displayed or not.
  66. */
  67. _showUploadButton: boolean,
  68. /**
  69. * Returns the selected virtual background object.
  70. */
  71. _virtualBackground: any,
  72. /**
  73. * The redux {@code dispatch} function.
  74. */
  75. dispatch: Function,
  76. /**
  77. * The initial options copied in the state for the {@code VirtualBackground} component.
  78. *
  79. * NOTE: currently used only for electron in order to open the dialog in the correct state after desktop sharing
  80. * selection.
  81. */
  82. initialOptions: Object
  83. }
  84. const onError = (event: any) => {
  85. event.target.style.display = 'none';
  86. };
  87. /**
  88. * Maps (parts of) the redux state to the associated props for the
  89. * {@code VirtualBackground} component.
  90. *
  91. * @param {Object} state - The Redux state.
  92. * @private
  93. * @returns {{Props}}
  94. */
  95. function _mapStateToProps(state: any): Object {
  96. const { localFlipX } = state['features/base/settings'];
  97. const dynamicBrandingImages = state['features/dynamic-branding'].virtualBackgrounds;
  98. const hasBrandingImages = Boolean(dynamicBrandingImages.length);
  99. return {
  100. _localFlipX: Boolean(localFlipX),
  101. _images: (hasBrandingImages && dynamicBrandingImages) || IMAGES,
  102. _virtualBackground: state['features/virtual-background'],
  103. _selectedThumbnail: state['features/virtual-background'].selectedThumbnail,
  104. _showUploadButton: !(hasBrandingImages || state['features/base/config'].disableAddingBackgroundImages),
  105. _jitsiTrack: getLocalVideoTrack(state['features/base/tracks'])?.jitsiTrack,
  106. _multiStreamModeEnabled: getMultipleVideoSendingSupportFeatureFlag(state)
  107. };
  108. }
  109. const VirtualBackgroundDialog = translate(connect(_mapStateToProps)(VirtualBackground));
  110. const useStyles = makeStyles((theme: any) => {
  111. return {
  112. container: {
  113. display: 'flex',
  114. flexDirection: 'column'
  115. },
  116. dialog: {
  117. alignSelf: 'flex-start',
  118. marginLeft: '-10px',
  119. position: 'relative',
  120. maxHeight: '300px',
  121. color: 'white',
  122. display: 'inline-grid',
  123. gridTemplateColumns: 'auto auto auto auto auto',
  124. columnGap: '9px',
  125. cursor: 'pointer',
  126. // @ts-ignore
  127. [[ '& .desktop-share:hover',
  128. '& .thumbnail:hover',
  129. '& .blur:hover',
  130. '& .slight-blur:hover',
  131. '& .virtual-background-none:hover' ]]: {
  132. opacity: 0.5,
  133. border: '2px solid #99bbf3'
  134. },
  135. '& .background-option': {
  136. marginTop: `${theme.spacing(2)}px`,
  137. borderRadius: `${theme.shape.borderRadius}px`,
  138. height: '60px',
  139. width: '107px',
  140. textAlign: 'center',
  141. justifyContent: 'center',
  142. fontWeight: 'bold',
  143. boxSizing: 'border-box',
  144. display: 'flex',
  145. alignItems: 'center'
  146. },
  147. '& thumbnail-container': {
  148. position: 'relative',
  149. '&:focus-within .thumbnail ~ .delete-image-icon': {
  150. display: 'block'
  151. }
  152. },
  153. '& .thumbnail': {
  154. objectFit: 'cover'
  155. },
  156. '& .thumbnail:hover ~ .delete-image-icon': {
  157. display: 'block'
  158. },
  159. '& .thumbnail-selected': {
  160. objectFit: 'cover',
  161. border: '2px solid #246fe5'
  162. },
  163. '& .blur': {
  164. boxShadow: 'inset 0 0 12px #000000',
  165. background: '#7e8287',
  166. padding: '0 10px'
  167. },
  168. '& .blur-selected': {
  169. border: '2px solid #246fe5'
  170. },
  171. '& .slight-blur': {
  172. boxShadow: 'inset 0 0 12px #000000',
  173. background: '#a4a4a4',
  174. padding: '0 10px'
  175. },
  176. '& .slight-blur-selected': {
  177. border: '2px solid #246fe5'
  178. },
  179. '& .virtual-background-none': {
  180. background: '#525252',
  181. padding: '0 10px'
  182. },
  183. '& .none-selected': {
  184. border: '2px solid #246fe5'
  185. },
  186. '& .desktop-share': {
  187. background: '#525252'
  188. },
  189. '& .desktop-share-selected': {
  190. border: '2px solid #246fe5',
  191. padding: '0 10px'
  192. },
  193. '& delete-image-icon': {
  194. background: '#3d3d3d',
  195. position: 'absolute',
  196. display: 'none',
  197. left: '96px',
  198. bottom: '51px',
  199. '&:hover': {
  200. display: 'block'
  201. },
  202. '@media (max-width: 632px)': {
  203. left: '51px'
  204. }
  205. },
  206. '@media (max-width: 720px)': {
  207. gridTemplateColumns: 'auto auto auto auto'
  208. },
  209. '@media (max-width: 632px)': {
  210. gridTemplateColumns: 'auto auto auto auto auto',
  211. fontSize: '1.5vw',
  212. // @ts-ignore
  213. [[ '& .desktop-share:hover',
  214. '& .thumbnail:hover',
  215. '& .blur:hover',
  216. '& .slight-blur:hover',
  217. '& .virtual-background-none:hover' ]]: {
  218. height: '60px',
  219. width: '60px'
  220. },
  221. // @ts-ignore
  222. [[ '& .desktop-share',
  223. '& .virtual-background-none,',
  224. '& .thumbnail,',
  225. '& .blur,',
  226. '& .slight-blur' ]]: {
  227. height: '60px',
  228. width: '60px'
  229. },
  230. // @ts-ignore
  231. [[ '& .desktop-share-selected',
  232. '& .thumbnail-selected',
  233. '& .none-selected',
  234. '& .blur-selected',
  235. '& .slight-blur-selected' ]]: {
  236. height: '60px',
  237. width: '60px'
  238. }
  239. },
  240. '@media (max-width: 360px)': {
  241. gridTemplateColumns: 'auto auto auto auto'
  242. },
  243. '@media (max-width: 319px)': {
  244. gridTemplateColumns: 'auto auto'
  245. }
  246. },
  247. dialogMarginTop: {
  248. marginTop: '44px'
  249. },
  250. virtualBackgroundLoading: {
  251. overflow: 'hidden',
  252. position: 'fixed',
  253. left: '50%',
  254. marginTop: '10px',
  255. transform: 'translateX(-50%)'
  256. }
  257. };
  258. });
  259. /**
  260. * Renders virtual background dialog.
  261. *
  262. * @returns {ReactElement}
  263. */
  264. function VirtualBackground({
  265. _images,
  266. _jitsiTrack,
  267. _localFlipX,
  268. _selectedThumbnail,
  269. _showUploadButton,
  270. _virtualBackground,
  271. _multiStreamModeEnabled,
  272. dispatch,
  273. initialOptions,
  274. t
  275. }: Props) {
  276. const classes = useStyles();
  277. const [ previewIsLoaded, setPreviewIsLoaded ] = useState(false);
  278. const [ options, setOptions ] = useState<any>({ ...initialOptions });
  279. const localImages = jitsiLocalStorage.getItem('virtualBackgrounds');
  280. const [ storedImages, setStoredImages ] = useState<Array<Image>>((localImages && Bourne.parse(localImages)) || []);
  281. const [ loading, setLoading ] = useState(false);
  282. let { disableScreensharingVirtualBackground } = useSelector((state: IState) => state['features/base/config']);
  283. // Disable screenshare as virtual background in multi-stream mode.
  284. disableScreensharingVirtualBackground = disableScreensharingVirtualBackground || _multiStreamModeEnabled;
  285. const [ activeDesktopVideo ] = useState(_virtualBackground?.virtualSource?.videoType === VIDEO_TYPE.DESKTOP
  286. ? _virtualBackground.virtualSource
  287. : null);
  288. const [ initialVirtualBackground ] = useState(_virtualBackground);
  289. const deleteStoredImage = useCallback(e => {
  290. const imageId = e.currentTarget.getAttribute('data-imageid');
  291. setStoredImages(storedImages.filter(item => item.id !== imageId));
  292. }, [ storedImages ]);
  293. const deleteStoredImageKeyPress = useCallback(e => {
  294. if (e.key === ' ' || e.key === 'Enter') {
  295. e.preventDefault();
  296. deleteStoredImage(e);
  297. }
  298. }, [ deleteStoredImage ]);
  299. /**
  300. * Updates stored images on local storage.
  301. */
  302. useEffect(() => {
  303. try {
  304. jitsiLocalStorage.setItem('virtualBackgrounds', JSON.stringify(storedImages));
  305. } catch (err) {
  306. // Preventing localStorage QUOTA_EXCEEDED_ERR
  307. err && setStoredImages(storedImages.slice(1));
  308. }
  309. if (storedImages.length === BACKGROUNDS_LIMIT) {
  310. setStoredImages(storedImages.slice(1));
  311. }
  312. }, [ storedImages ]);
  313. const enableBlur = useCallback(async () => {
  314. setOptions({
  315. backgroundType: VIRTUAL_BACKGROUND_TYPE.BLUR,
  316. enabled: true,
  317. blurValue: 25,
  318. selectedThumbnail: 'blur'
  319. });
  320. logger.info('"Blur" option set for virtual background preview!');
  321. }, []);
  322. const enableBlurKeyPress = useCallback(e => {
  323. if (e.key === ' ' || e.key === 'Enter') {
  324. e.preventDefault();
  325. enableBlur();
  326. }
  327. }, [ enableBlur ]);
  328. const enableSlideBlur = useCallback(async () => {
  329. setOptions({
  330. backgroundType: VIRTUAL_BACKGROUND_TYPE.BLUR,
  331. enabled: true,
  332. blurValue: 8,
  333. selectedThumbnail: 'slight-blur'
  334. });
  335. logger.info('"Slight-blur" option set for virtual background preview!');
  336. }, []);
  337. const enableSlideBlurKeyPress = useCallback(e => {
  338. if (e.key === ' ' || e.key === 'Enter') {
  339. e.preventDefault();
  340. enableSlideBlur();
  341. }
  342. }, [ enableSlideBlur ]);
  343. const shareDesktop = useCallback(async () => {
  344. if (disableScreensharingVirtualBackground) {
  345. return;
  346. }
  347. let isCancelled = false, url;
  348. try {
  349. url = await createLocalTrack('desktop', '');
  350. } catch (e: any) {
  351. if (e.name === JitsiTrackErrors.SCREENSHARING_USER_CANCELED) {
  352. isCancelled = true;
  353. } else {
  354. logger.error(e);
  355. }
  356. }
  357. if (!url) {
  358. if (!isCancelled) {
  359. dispatch(showErrorNotification({
  360. titleKey: 'virtualBackground.desktopShareError'
  361. }, NOTIFICATION_TIMEOUT_TYPE.LONG));
  362. logger.error('Could not create desktop share as a virtual background!');
  363. }
  364. /**
  365. * For electron createLocalTrack will open the {@code DesktopPicker} dialog and hide the
  366. * {@code VirtualBackgroundDialog}. That's why we need to reopen the {@code VirtualBackgroundDialog}
  367. * and restore the current state through {@code initialOptions} prop.
  368. */
  369. if (browser.isElectron()) {
  370. dispatch(openDialog(VirtualBackgroundDialog, { initialOptions: options }));
  371. }
  372. return;
  373. }
  374. const newOptions = {
  375. backgroundType: VIRTUAL_BACKGROUND_TYPE.DESKTOP_SHARE,
  376. enabled: true,
  377. selectedThumbnail: 'desktop-share',
  378. url
  379. };
  380. /**
  381. * For electron createLocalTrack will open the {@code DesktopPicker} dialog and hide the
  382. * {@code VirtualBackgroundDialog}. That's why we need to reopen the {@code VirtualBackgroundDialog}
  383. * and force it to show desktop share virtual background through {@code initialOptions} prop.
  384. */
  385. if (browser.isElectron()) {
  386. dispatch(openDialog(VirtualBackgroundDialog, { initialOptions: newOptions }));
  387. } else {
  388. setOptions(newOptions);
  389. logger.info('"Desktop-share" option set for virtual background preview!');
  390. }
  391. }, [ dispatch, options ]);
  392. const shareDesktopKeyPress = useCallback(e => {
  393. if (e.key === ' ' || e.key === 'Enter') {
  394. e.preventDefault();
  395. shareDesktop();
  396. }
  397. }, [ shareDesktop ]);
  398. const removeBackground = useCallback(async () => {
  399. setOptions({
  400. enabled: false,
  401. selectedThumbnail: 'none'
  402. });
  403. logger.info('"None" option set for virtual background preview!');
  404. }, []);
  405. const removeBackgroundKeyPress = useCallback(e => {
  406. if (e.key === ' ' || e.key === 'Enter') {
  407. e.preventDefault();
  408. removeBackground();
  409. }
  410. }, [ removeBackground ]);
  411. const setUploadedImageBackground = useCallback(async e => {
  412. const imageId = e.currentTarget.getAttribute('data-imageid');
  413. const image = storedImages.find(img => img.id === imageId);
  414. if (image) {
  415. setOptions({
  416. backgroundType: 'image',
  417. enabled: true,
  418. url: image.src,
  419. selectedThumbnail: image.id
  420. });
  421. logger.info('Uploaded image set for virtual background preview!');
  422. }
  423. }, [ storedImages ]);
  424. const setImageBackground = useCallback(async e => {
  425. const imageId = e.currentTarget.getAttribute('data-imageid');
  426. const image = _images.find(img => img.id === imageId);
  427. if (image) {
  428. try {
  429. const url = await toDataURL(image.src);
  430. setOptions({
  431. backgroundType: 'image',
  432. enabled: true,
  433. url,
  434. selectedThumbnail: image.id
  435. });
  436. logger.info('Image set for virtual background preview!');
  437. } catch (err) {
  438. logger.error('Could not fetch virtual background image:', err);
  439. }
  440. setLoading(false);
  441. }
  442. }, []);
  443. const setImageBackgroundKeyPress = useCallback(e => {
  444. if (e.key === ' ' || e.key === 'Enter') {
  445. e.preventDefault();
  446. setImageBackground(e);
  447. }
  448. }, [ setImageBackground ]);
  449. const setUploadedImageBackgroundKeyPress = useCallback(e => {
  450. if (e.key === ' ' || e.key === 'Enter') {
  451. e.preventDefault();
  452. setUploadedImageBackground(e);
  453. }
  454. }, [ setUploadedImageBackground ]);
  455. const applyVirtualBackground = useCallback(async () => {
  456. if (activeDesktopVideo) {
  457. await activeDesktopVideo.dispose();
  458. }
  459. setLoading(true);
  460. await dispatch(toggleBackgroundEffect(options, _jitsiTrack));
  461. await setLoading(false);
  462. if (_localFlipX && options.backgroundType === VIRTUAL_BACKGROUND_TYPE.DESKTOP_SHARE) {
  463. dispatch(updateSettings({
  464. localFlipX: !_localFlipX
  465. }));
  466. } else {
  467. // Set x scale to default value.
  468. dispatch(updateSettings({
  469. localFlipX: true
  470. }));
  471. }
  472. dispatch(hideDialog());
  473. logger.info(`Virtual background type: '${typeof options.backgroundType === 'undefined'
  474. ? 'none' : options.backgroundType}' applied!`);
  475. dispatch(virtualBackgroundTrackChanged());
  476. }, [ dispatch, options, _localFlipX ]);
  477. // Prevent the selection of a new virtual background if it has not been applied by default
  478. const cancelVirtualBackground = useCallback(async () => {
  479. await setOptions({
  480. backgroundType: initialVirtualBackground.backgroundType,
  481. enabled: initialVirtualBackground.backgroundEffectEnabled,
  482. url: initialVirtualBackground.virtualSource,
  483. selectedThumbnail: initialVirtualBackground.selectedThumbnail,
  484. blurValue: initialVirtualBackground.blurValue
  485. });
  486. dispatch(hideDialog());
  487. }, []);
  488. const loadedPreviewState = useCallback(async loaded => {
  489. await setPreviewIsLoaded(loaded);
  490. }, []);
  491. return (
  492. <Dialog
  493. hideCancelButton = { false }
  494. okKey = { 'virtualBackground.apply' }
  495. onCancel = { cancelVirtualBackground }
  496. onSubmit = { applyVirtualBackground }
  497. submitDisabled = { !options || loading || !previewIsLoaded }
  498. titleKey = { 'virtualBackground.title' } >
  499. <VirtualBackgroundPreview
  500. loadedPreview = { loadedPreviewState }
  501. options = { options } />
  502. {loading ? (
  503. <div className = { classes.virtualBackgroundLoading }>
  504. <Spinner
  505. // @ts-ignore
  506. isCompleting = { false }
  507. size = 'medium' />
  508. </div>
  509. ) : (
  510. <div className = { classes.container }>
  511. {_showUploadButton
  512. && <UploadImageButton
  513. setLoading = { setLoading }
  514. setOptions = { setOptions }
  515. setStoredImages = { setStoredImages }
  516. showLabel = { previewIsLoaded }
  517. storedImages = { storedImages } />}
  518. <div
  519. className = { clsx(classes.dialog, { [classes.dialogMarginTop]: previewIsLoaded }) }
  520. role = 'radiogroup'
  521. tabIndex = { -1 }>
  522. <Tooltip
  523. content = { t('virtualBackground.removeBackground') }
  524. position = { 'top' }>
  525. <div
  526. aria-checked = { _selectedThumbnail === 'none' }
  527. aria-label = { t('virtualBackground.removeBackground') }
  528. className = { clsx('background-option', 'virtual-background-none', {
  529. 'none-selected': _selectedThumbnail === 'none'
  530. }) }
  531. onClick = { removeBackground }
  532. onKeyPress = { removeBackgroundKeyPress }
  533. role = 'radio'
  534. tabIndex = { 0 } >
  535. {t('virtualBackground.none')}
  536. </div>
  537. </Tooltip>
  538. <Tooltip
  539. content = { t('virtualBackground.slightBlur') }
  540. position = { 'top' }>
  541. <div
  542. aria-checked = { _selectedThumbnail === 'slight-blur' }
  543. aria-label = { t('virtualBackground.slightBlur') }
  544. className = { clsx('background-option', 'slight-blur', {
  545. 'slight-blur-selected': _selectedThumbnail === 'slight-blur'
  546. }) }
  547. onClick = { enableSlideBlur }
  548. onKeyPress = { enableSlideBlurKeyPress }
  549. role = 'radio'
  550. tabIndex = { 0 }>
  551. {t('virtualBackground.slightBlur')}
  552. </div>
  553. </Tooltip>
  554. <Tooltip
  555. content = { t('virtualBackground.blur') }
  556. position = { 'top' }>
  557. <div
  558. aria-checked = { _selectedThumbnail === 'blur' }
  559. aria-label = { t('virtualBackground.blur') }
  560. className = { clsx('background-option', 'blur', {
  561. 'blur-selected': _selectedThumbnail === 'blur'
  562. }) }
  563. onClick = { enableBlur }
  564. onKeyPress = { enableBlurKeyPress }
  565. role = 'radio'
  566. tabIndex = { 0 }>
  567. {t('virtualBackground.blur')}
  568. </div>
  569. </Tooltip>
  570. {!disableScreensharingVirtualBackground && (
  571. <Tooltip
  572. content = { t('virtualBackground.desktopShare') }
  573. position = { 'top' }>
  574. <div
  575. aria-checked = { _selectedThumbnail === 'desktop-share' }
  576. aria-label = { t('virtualBackground.desktopShare') }
  577. className = { clsx('background-option', 'desktop-share', {
  578. 'desktop-share-selected': _selectedThumbnail === 'desktop-share'
  579. }) }
  580. onClick = { shareDesktop }
  581. onKeyPress = { shareDesktopKeyPress }
  582. role = 'radio'
  583. tabIndex = { 0 }>
  584. <Icon
  585. className = 'share-desktop-icon'
  586. size = { 30 }
  587. src = { IconShareDesktop } />
  588. </div>
  589. </Tooltip>
  590. )}
  591. {_images.map(image => (
  592. <Tooltip
  593. content = { image.tooltip && t(`virtualBackground.${image.tooltip}`) }
  594. key = { image.id }
  595. position = { 'top' }>
  596. <img
  597. alt = { image.tooltip && t(`virtualBackground.${image.tooltip}`) }
  598. aria-checked = { options.selectedThumbnail === image.id
  599. || _selectedThumbnail === image.id }
  600. className = {
  601. options.selectedThumbnail === image.id || _selectedThumbnail === image.id
  602. ? 'background-option thumbnail-selected' : 'background-option thumbnail' }
  603. data-imageid = { image.id }
  604. onClick = { setImageBackground }
  605. onError = { onError }
  606. onKeyPress = { setImageBackgroundKeyPress }
  607. role = 'radio'
  608. src = { image.src }
  609. tabIndex = { 0 } />
  610. </Tooltip>
  611. ))}
  612. {storedImages.map((image, index) => (
  613. <div
  614. className = { 'thumbnail-container' }
  615. key = { image.id }>
  616. <img
  617. alt = { t('virtualBackground.uploadedImage', { index: index + 1 }) }
  618. aria-checked = { _selectedThumbnail === image.id }
  619. className = { clsx('background-option', {
  620. 'thumbnail-selected': _selectedThumbnail === image.id,
  621. 'thumbnail': _selectedThumbnail !== image.id
  622. }) }
  623. data-imageid = { image.id }
  624. onClick = { setUploadedImageBackground }
  625. onError = { onError }
  626. onKeyPress = { setUploadedImageBackgroundKeyPress }
  627. role = 'radio'
  628. src = { image.src }
  629. tabIndex = { 0 } />
  630. <Icon
  631. ariaLabel = { t('virtualBackground.deleteImage') }
  632. className = { 'delete-image-icon' }
  633. data-imageid = { image.id }
  634. onClick = { deleteStoredImage }
  635. onKeyPress = { deleteStoredImageKeyPress }
  636. role = 'button'
  637. size = { 15 }
  638. src = { IconCloseSmall }
  639. tabIndex = { 0 } />
  640. </div>
  641. ))}
  642. </div>
  643. </div>
  644. )}
  645. </Dialog>
  646. );
  647. }
  648. export default VirtualBackgroundDialog;