2024-07-19 04:24:10 +08:00
|
|
|
import React, {
|
|
|
|
useState, useRef, useContext, useEffect,
|
|
|
|
} from 'react';
|
2021-08-31 03:56:29 +08:00
|
|
|
import { findDOMNode } from 'react-dom';
|
2021-07-20 04:19:06 +08:00
|
|
|
import { defineMessages, injectIntl } from 'react-intl';
|
|
|
|
import PropTypes from 'prop-types';
|
2021-10-28 19:58:39 +08:00
|
|
|
import Styled from './styles';
|
2021-07-20 04:19:06 +08:00
|
|
|
import {
|
|
|
|
EFFECT_TYPES,
|
|
|
|
BLUR_FILENAME,
|
2024-05-29 21:26:11 +08:00
|
|
|
getImageNames,
|
2021-07-20 04:19:06 +08:00
|
|
|
getVirtualBackgroundThumbnail,
|
2021-08-04 03:24:08 +08:00
|
|
|
isVirtualBackgroundSupported,
|
2021-08-30 08:45:31 +08:00
|
|
|
} from '/imports/ui/services/virtual-background/service';
|
2022-04-12 01:09:13 +08:00
|
|
|
import { CustomVirtualBackgroundsContext } from './context';
|
2022-06-01 23:05:16 +08:00
|
|
|
import VirtualBgService from '/imports/ui/components/video-preview/virtual-background/service';
|
2022-07-06 21:38:40 +08:00
|
|
|
import logger from '/imports/startup/client/logger';
|
|
|
|
import withFileReader from '/imports/ui/components/common/file-reader/component';
|
2022-07-07 03:03:55 +08:00
|
|
|
import Skeleton, { SkeletonTheme } from 'react-loading-skeleton';
|
|
|
|
import 'react-loading-skeleton/dist/skeleton.css';
|
2024-05-29 21:26:11 +08:00
|
|
|
import { getSettingsSingletonInstance } from '/imports/ui/services/settings';
|
2024-07-19 04:24:10 +08:00
|
|
|
import { getStorageSingletonInstance } from '/imports/ui/services/storage';
|
2021-07-20 04:19:06 +08:00
|
|
|
|
2022-07-06 21:38:40 +08:00
|
|
|
const { MIME_TYPES_ALLOWED, MAX_FILE_SIZE } = VirtualBgService;
|
2021-07-20 04:19:06 +08:00
|
|
|
|
|
|
|
const propTypes = {
|
|
|
|
intl: PropTypes.shape({
|
|
|
|
formatMessage: PropTypes.func.isRequired,
|
|
|
|
}).isRequired,
|
|
|
|
handleVirtualBgSelected: PropTypes.func.isRequired,
|
|
|
|
locked: PropTypes.bool.isRequired,
|
|
|
|
showThumbnails: PropTypes.bool,
|
|
|
|
initialVirtualBgState: PropTypes.shape({
|
|
|
|
type: PropTypes.string.isRequired,
|
|
|
|
name: PropTypes.string,
|
|
|
|
}),
|
|
|
|
};
|
|
|
|
|
2022-07-07 03:03:55 +08:00
|
|
|
const SKELETON_COUNT = 5;
|
2024-05-29 21:26:11 +08:00
|
|
|
|
2024-06-14 21:30:48 +08:00
|
|
|
const shouldEnableBackgroundUpload = (isCustomVirtualBackgroundsEnabled) => {
|
2024-05-29 21:26:11 +08:00
|
|
|
const VIRTUAL_BACKGROUNDS_CONFIG = window.meetingClientSettings.public.virtualBackgrounds;
|
|
|
|
const ENABLE_UPLOAD = VIRTUAL_BACKGROUNDS_CONFIG.enableVirtualBackgroundUpload;
|
2024-06-14 21:30:48 +08:00
|
|
|
return ENABLE_UPLOAD && isCustomVirtualBackgroundsEnabled;
|
2024-05-29 21:26:11 +08:00
|
|
|
};
|
2022-07-07 03:03:55 +08:00
|
|
|
|
2024-06-11 21:05:08 +08:00
|
|
|
const defaultInitialVirtualBgState = {
|
|
|
|
type: EFFECT_TYPES.NONE_TYPE,
|
|
|
|
};
|
|
|
|
|
2021-07-20 04:19:06 +08:00
|
|
|
const VirtualBgSelector = ({
|
|
|
|
intl,
|
|
|
|
handleVirtualBgSelected,
|
|
|
|
locked,
|
2024-06-11 21:05:08 +08:00
|
|
|
showThumbnails = false,
|
|
|
|
initialVirtualBgState = defaultInitialVirtualBgState,
|
2022-07-06 21:38:40 +08:00
|
|
|
readFile,
|
2024-06-14 21:30:48 +08:00
|
|
|
isCustomVirtualBackgroundsEnabled,
|
2021-07-20 04:19:06 +08:00
|
|
|
}) => {
|
2024-05-29 21:26:11 +08:00
|
|
|
const IMAGE_NAMES = getImageNames();
|
|
|
|
|
|
|
|
const intlMessages = defineMessages({
|
|
|
|
virtualBackgroundSettingsLabel: {
|
|
|
|
id: 'app.videoPreview.webcamVirtualBackgroundLabel',
|
|
|
|
description: 'Label for the virtual background',
|
|
|
|
},
|
|
|
|
virtualBackgroundSettingsDisabledLabel: {
|
|
|
|
id: 'app.videoPreview.webcamVirtualBackgroundDisabledLabel',
|
|
|
|
description: 'Label for the unsupported virtual background',
|
|
|
|
},
|
|
|
|
noneLabel: {
|
|
|
|
id: 'app.video.virtualBackground.none',
|
|
|
|
description: 'Label for no virtual background selected',
|
|
|
|
},
|
|
|
|
customLabel: {
|
|
|
|
id: 'app.video.virtualBackground.custom',
|
|
|
|
description: 'Label for custom virtual background selected',
|
|
|
|
},
|
|
|
|
removeLabel: {
|
|
|
|
id: 'app.video.virtualBackground.remove',
|
|
|
|
description: 'Label for remove custom virtual background',
|
|
|
|
},
|
|
|
|
blurLabel: {
|
|
|
|
id: 'app.video.virtualBackground.blur',
|
|
|
|
description: 'Label for the blurred camera option',
|
|
|
|
},
|
|
|
|
camBgAriaDesc: {
|
|
|
|
id: 'app.video.virtualBackground.camBgAriaDesc',
|
|
|
|
description: 'Label for virtual background button aria',
|
|
|
|
},
|
|
|
|
customDesc: {
|
|
|
|
id: 'app.video.virtualBackground.button.customDesc',
|
|
|
|
description: 'Aria description for upload virtual background button',
|
|
|
|
},
|
|
|
|
background: {
|
|
|
|
id: 'app.video.virtualBackground.background',
|
|
|
|
description: 'Label for the background word',
|
|
|
|
},
|
|
|
|
backgroundWithIndex: {
|
|
|
|
id: 'app.video.virtualBackground.backgroundWithIndex',
|
|
|
|
description: 'Label for the background word indexed',
|
|
|
|
},
|
|
|
|
...IMAGE_NAMES.reduce((prev, imageName) => {
|
|
|
|
const id = imageName.split('.').shift();
|
|
|
|
return {
|
|
|
|
...prev,
|
|
|
|
[id]: {
|
|
|
|
id: `app.video.virtualBackground.${id}`,
|
|
|
|
description: `Label for the ${id} camera option`,
|
|
|
|
defaultMessage: '{background} {index}',
|
|
|
|
},
|
|
|
|
};
|
|
|
|
}, {}),
|
|
|
|
});
|
|
|
|
|
2021-07-20 04:19:06 +08:00
|
|
|
const [currentVirtualBg, setCurrentVirtualBg] = useState({
|
|
|
|
...initialVirtualBgState,
|
|
|
|
});
|
|
|
|
|
2021-08-19 01:24:19 +08:00
|
|
|
const inputElementsRef = useRef([]);
|
2022-06-01 23:05:16 +08:00
|
|
|
const customBgSelectorRef = useRef(null);
|
2021-08-19 01:24:19 +08:00
|
|
|
|
2022-04-12 01:09:13 +08:00
|
|
|
const {
|
|
|
|
dispatch,
|
|
|
|
loaded,
|
2022-07-08 23:16:37 +08:00
|
|
|
defaultSetUp,
|
2022-07-08 05:59:30 +08:00
|
|
|
backgrounds,
|
2022-04-12 01:09:13 +08:00
|
|
|
loadFromDB,
|
|
|
|
} = useContext(CustomVirtualBackgroundsContext);
|
|
|
|
|
2022-06-01 23:05:16 +08:00
|
|
|
const { MIME_TYPES_ALLOWED } = VirtualBgService;
|
|
|
|
|
2022-04-12 01:09:13 +08:00
|
|
|
useEffect(() => {
|
2024-06-14 21:30:48 +08:00
|
|
|
if (shouldEnableBackgroundUpload(isCustomVirtualBackgroundsEnabled)) {
|
2022-07-09 04:01:57 +08:00
|
|
|
if (!defaultSetUp) {
|
|
|
|
const defaultBackgrounds = ['Blur', ...IMAGE_NAMES].map((imageName) => ({
|
|
|
|
uniqueId: imageName,
|
|
|
|
custom: false,
|
|
|
|
lastActivityDate: Date.now(),
|
|
|
|
}));
|
|
|
|
dispatch({
|
|
|
|
type: 'setDefault',
|
|
|
|
backgrounds: defaultBackgrounds,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
if (!loaded) loadFromDB();
|
2022-07-08 23:16:37 +08:00
|
|
|
}
|
2024-06-14 21:30:48 +08:00
|
|
|
}, [isCustomVirtualBackgroundsEnabled]);
|
2022-04-12 01:09:13 +08:00
|
|
|
|
2024-07-19 04:24:10 +08:00
|
|
|
const _virtualBgSelected = (type, name, index, customParams) => handleVirtualBgSelected(type, name, customParams)
|
|
|
|
.then((switched) => {
|
|
|
|
// Reset to the base NONE_TYPE effect if it failed because the expected
|
|
|
|
// behaviour from upstream's method is to actually stop/reset the effect
|
|
|
|
// service if it fails
|
|
|
|
if (!switched) {
|
|
|
|
return setCurrentVirtualBg({ type: EFFECT_TYPES.NONE_TYPE });
|
|
|
|
}
|
|
|
|
|
|
|
|
setCurrentVirtualBg({ type, name, uniqueId: customParams?.uniqueId });
|
|
|
|
|
|
|
|
if (!index || index < 0) return;
|
|
|
|
|
|
|
|
if (!shouldEnableBackgroundUpload(isCustomVirtualBackgroundsEnabled)) {
|
|
|
|
findDOMNode(inputElementsRef.current[index]).focus();
|
|
|
|
} else {
|
|
|
|
if (customParams) {
|
|
|
|
dispatch({
|
|
|
|
type: 'update',
|
|
|
|
background: {
|
|
|
|
filename: name,
|
|
|
|
uniqueId: customParams.uniqueId,
|
|
|
|
data: customParams.file,
|
|
|
|
custom: true,
|
|
|
|
lastActivityDate: Date.now(),
|
|
|
|
},
|
|
|
|
});
|
2022-07-08 23:16:37 +08:00
|
|
|
} else {
|
2024-07-19 04:24:10 +08:00
|
|
|
dispatch({
|
|
|
|
type: 'update',
|
|
|
|
background: {
|
|
|
|
uniqueId: name,
|
|
|
|
custom: false,
|
|
|
|
lastActivityDate: Date.now(),
|
|
|
|
},
|
|
|
|
});
|
2021-08-30 08:45:31 +08:00
|
|
|
}
|
2024-07-19 04:24:10 +08:00
|
|
|
findDOMNode(inputElementsRef.current[0]).focus();
|
|
|
|
}
|
|
|
|
});
|
2021-07-20 04:19:06 +08:00
|
|
|
|
|
|
|
const renderDropdownSelector = () => {
|
2021-08-04 03:24:08 +08:00
|
|
|
const disabled = locked || !isVirtualBackgroundSupported();
|
2024-05-29 21:26:11 +08:00
|
|
|
const IMAGE_NAMES = getImageNames();
|
2021-08-04 03:24:08 +08:00
|
|
|
|
2021-07-20 04:19:06 +08:00
|
|
|
return (
|
2021-10-28 19:58:39 +08:00
|
|
|
<div>
|
|
|
|
<Styled.Select
|
2021-07-20 04:19:06 +08:00
|
|
|
value={JSON.stringify(currentVirtualBg)}
|
2021-08-04 03:24:08 +08:00
|
|
|
disabled={disabled}
|
2024-07-19 04:24:10 +08:00
|
|
|
onChange={(event) => {
|
2021-07-20 04:19:06 +08:00
|
|
|
const { type, name } = JSON.parse(event.target.value);
|
|
|
|
_virtualBgSelected(type, name);
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
<option value={JSON.stringify({ type: EFFECT_TYPES.NONE_TYPE })}>
|
|
|
|
{intl.formatMessage(intlMessages.noneLabel)}
|
|
|
|
</option>
|
|
|
|
|
|
|
|
<option value={JSON.stringify({ type: EFFECT_TYPES.BLUR_TYPE })}>
|
|
|
|
{intl.formatMessage(intlMessages.blurLabel)}
|
|
|
|
</option>
|
|
|
|
|
2021-08-30 08:45:31 +08:00
|
|
|
{IMAGE_NAMES.map((imageName, i) => {
|
|
|
|
const k = `${imageName}-${i}`;
|
|
|
|
return (
|
2024-07-19 04:24:10 +08:00
|
|
|
<option
|
|
|
|
key={k}
|
|
|
|
value={JSON.stringify({
|
|
|
|
type: EFFECT_TYPES.IMAGE_TYPE,
|
|
|
|
name: imageName,
|
|
|
|
})}
|
|
|
|
>
|
|
|
|
{imageName.split('.')[0]}
|
2021-08-30 08:45:31 +08:00
|
|
|
</option>
|
|
|
|
);
|
|
|
|
})}
|
2021-10-28 19:58:39 +08:00
|
|
|
</Styled.Select>
|
2021-07-20 04:19:06 +08:00
|
|
|
</div>
|
|
|
|
);
|
2024-07-19 04:24:10 +08:00
|
|
|
};
|
2021-07-20 04:19:06 +08:00
|
|
|
|
2022-04-12 01:09:13 +08:00
|
|
|
const handleCustomBgChange = (event) => {
|
|
|
|
const file = event.target.files[0];
|
2022-06-01 03:32:58 +08:00
|
|
|
|
2022-07-06 21:38:40 +08:00
|
|
|
const onSuccess = (background) => {
|
|
|
|
dispatch({
|
|
|
|
type: 'new',
|
2022-07-26 02:14:27 +08:00
|
|
|
background: {
|
|
|
|
...background,
|
|
|
|
custom: true,
|
|
|
|
lastActivityDate: Date.now(),
|
|
|
|
},
|
2022-07-06 21:38:40 +08:00
|
|
|
});
|
2023-03-21 04:17:27 +08:00
|
|
|
const { filename, data, uniqueId } = background;
|
|
|
|
_virtualBgSelected(
|
|
|
|
EFFECT_TYPES.IMAGE_TYPE,
|
|
|
|
filename,
|
|
|
|
0,
|
|
|
|
{ file: data, uniqueId },
|
|
|
|
);
|
2022-07-06 21:38:40 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
const onError = (error) => {
|
|
|
|
logger.warn({
|
|
|
|
logCode: 'read_file_error',
|
|
|
|
extraInfo: {
|
|
|
|
errorName: error.name,
|
|
|
|
errorMessage: error.message,
|
|
|
|
},
|
|
|
|
}, error.message);
|
|
|
|
};
|
|
|
|
|
|
|
|
readFile(file, onSuccess, onError);
|
|
|
|
};
|
2022-04-12 01:09:13 +08:00
|
|
|
|
2021-07-20 04:19:06 +08:00
|
|
|
const renderThumbnailSelector = () => {
|
2021-08-04 03:24:08 +08:00
|
|
|
const disabled = locked || !isVirtualBackgroundSupported();
|
2024-05-29 21:26:11 +08:00
|
|
|
const Settings = getSettingsSingletonInstance();
|
2024-07-19 04:24:10 +08:00
|
|
|
const { isRTL } = Settings.application;
|
2024-05-29 21:26:11 +08:00
|
|
|
const IMAGE_NAMES = getImageNames();
|
2021-08-04 03:24:08 +08:00
|
|
|
|
2024-07-19 04:24:10 +08:00
|
|
|
const renderBlurButton = (index) => (
|
|
|
|
<Styled.ThumbnailButtonWrapper
|
|
|
|
key={`blur-${index}`}
|
|
|
|
>
|
|
|
|
<Styled.ThumbnailButton
|
|
|
|
background={getVirtualBackgroundThumbnail(BLUR_FILENAME)}
|
|
|
|
aria-label={intl.formatMessage(intlMessages.blurLabel)}
|
|
|
|
label={intl.formatMessage(intlMessages.blurLabel)}
|
|
|
|
aria-describedby="vr-cam-btn-blur"
|
|
|
|
tabIndex={disabled ? -1 : 0}
|
|
|
|
hideLabel
|
|
|
|
aria-pressed={currentVirtualBg?.name?.includes('blur') || currentVirtualBg?.name?.includes('Blur')}
|
|
|
|
disabled={disabled}
|
|
|
|
ref={(ref) => { inputElementsRef.current[index] = ref; }}
|
|
|
|
onClick={() => _virtualBgSelected(EFFECT_TYPES.BLUR_TYPE, 'Blur', index)}
|
|
|
|
/>
|
|
|
|
<div aria-hidden className="sr-only" id="vr-cam-btn-blur">
|
|
|
|
{intl.formatMessage(intlMessages.camBgAriaDesc, { 0: EFFECT_TYPES.BLUR_TYPE })}
|
|
|
|
</div>
|
|
|
|
</Styled.ThumbnailButtonWrapper>
|
|
|
|
);
|
2022-07-08 23:16:37 +08:00
|
|
|
|
|
|
|
const renderDefaultButton = (imageName, index) => {
|
|
|
|
const label = intl.formatMessage(intlMessages[imageName.split('.').shift()], {
|
|
|
|
index: index + 1,
|
|
|
|
background: intl.formatMessage(intlMessages.background),
|
|
|
|
});
|
|
|
|
|
|
|
|
return (
|
|
|
|
<Styled.ThumbnailButtonWrapper
|
|
|
|
key={`${imageName}-${index + 1}`}
|
|
|
|
>
|
|
|
|
<Styled.ThumbnailButton
|
|
|
|
id={`${imageName}-${index + 1}`}
|
|
|
|
label={label}
|
|
|
|
tabIndex={disabled ? -1 : 0}
|
|
|
|
role="button"
|
|
|
|
aria-label={label}
|
|
|
|
aria-describedby={`vr-cam-btn-${index + 1}`}
|
|
|
|
aria-pressed={currentVirtualBg?.name?.includes(imageName.split('.').shift())}
|
|
|
|
hideLabel
|
2024-07-19 04:24:10 +08:00
|
|
|
ref={(ref) => inputElementsRef.current[index] = ref}
|
2022-07-08 23:16:37 +08:00
|
|
|
onClick={() => _virtualBgSelected(EFFECT_TYPES.IMAGE_TYPE, imageName, index)}
|
|
|
|
disabled={disabled}
|
|
|
|
background={getVirtualBackgroundThumbnail(imageName)}
|
2022-09-13 01:10:57 +08:00
|
|
|
data-test="selectDefaultBackground"
|
2022-07-08 23:16:37 +08:00
|
|
|
/>
|
|
|
|
<div aria-hidden className="sr-only" id={`vr-cam-btn-${index + 1}`}>
|
|
|
|
{intl.formatMessage(intlMessages.camBgAriaDesc, { 0: label })}
|
|
|
|
</div>
|
|
|
|
</Styled.ThumbnailButtonWrapper>
|
2024-07-19 04:24:10 +08:00
|
|
|
);
|
2022-07-08 23:16:37 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
const renderCustomButton = (background, index) => {
|
|
|
|
const { filename, data, uniqueId } = background;
|
|
|
|
const label = intl.formatMessage(intlMessages.backgroundWithIndex, {
|
|
|
|
0: index + 1,
|
|
|
|
});
|
|
|
|
|
|
|
|
return (
|
|
|
|
<Styled.ThumbnailButtonWrapper
|
|
|
|
key={`${filename}-${index + 1}`}
|
|
|
|
>
|
|
|
|
<Styled.ThumbnailButton
|
|
|
|
id={`${filename}-${index + 1}`}
|
|
|
|
label={label}
|
|
|
|
tabIndex={disabled ? -1 : 0}
|
|
|
|
role="button"
|
|
|
|
aria-label={label}
|
|
|
|
aria-describedby={`vr-cam-btn-${index + 1}`}
|
|
|
|
aria-pressed={currentVirtualBg?.name?.includes(filename)}
|
|
|
|
hideLabel
|
2024-07-19 04:24:10 +08:00
|
|
|
ref={(ref) => inputElementsRef.current[index] = ref}
|
2022-07-08 23:16:37 +08:00
|
|
|
onClick={() => _virtualBgSelected(
|
|
|
|
EFFECT_TYPES.IMAGE_TYPE,
|
|
|
|
filename,
|
|
|
|
index,
|
|
|
|
{ file: data, uniqueId },
|
|
|
|
)}
|
|
|
|
disabled={disabled}
|
|
|
|
background={data}
|
2022-09-13 01:10:57 +08:00
|
|
|
data-test="selectCustomBackground"
|
2022-07-08 23:16:37 +08:00
|
|
|
/>
|
|
|
|
<Styled.ButtonWrapper>
|
|
|
|
<Styled.ButtonRemove
|
|
|
|
disabled={disabled}
|
|
|
|
label={intl.formatMessage(intlMessages.removeLabel)}
|
|
|
|
aria-label={intl.formatMessage(intlMessages.removeLabel)}
|
2022-09-30 23:22:14 +08:00
|
|
|
aria-describedby={`vr-cam-btn-${index + 1}`}
|
2022-07-08 23:16:37 +08:00
|
|
|
data-test="removeCustomBackground"
|
|
|
|
icon="close"
|
|
|
|
size="sm"
|
|
|
|
color="dark"
|
|
|
|
circle
|
|
|
|
hideLabel
|
|
|
|
onClick={() => {
|
|
|
|
dispatch({
|
|
|
|
type: 'delete',
|
|
|
|
uniqueId,
|
|
|
|
});
|
2023-03-21 04:17:27 +08:00
|
|
|
_virtualBgSelected(EFFECT_TYPES.NONE_TYPE);
|
2022-07-08 23:16:37 +08:00
|
|
|
}}
|
|
|
|
/>
|
|
|
|
</Styled.ButtonWrapper>
|
|
|
|
<div aria-hidden className="sr-only" id={`vr-cam-btn-${index + 1}`}>
|
|
|
|
{label}
|
|
|
|
</div>
|
|
|
|
</Styled.ThumbnailButtonWrapper>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
2022-07-09 04:01:57 +08:00
|
|
|
const renderInputButton = () => (
|
|
|
|
<>
|
|
|
|
<Styled.BgCustomButton
|
2024-07-19 04:24:10 +08:00
|
|
|
icon="plus"
|
2022-07-09 04:01:57 +08:00
|
|
|
label={intl.formatMessage(intlMessages.customLabel)}
|
2024-07-19 04:24:10 +08:00
|
|
|
aria-describedby="vr-cam-btn-custom"
|
2022-07-09 04:01:57 +08:00
|
|
|
hideLabel
|
|
|
|
tabIndex={disabled ? -1 : 0}
|
|
|
|
disabled={disabled}
|
|
|
|
onClick={() => {
|
|
|
|
if (customBgSelectorRef.current) {
|
|
|
|
customBgSelectorRef.current.click();
|
|
|
|
}
|
|
|
|
}}
|
2022-09-13 01:10:57 +08:00
|
|
|
data-test="inputBackgroundButton"
|
2022-07-09 04:01:57 +08:00
|
|
|
/>
|
|
|
|
<input
|
|
|
|
ref={customBgSelectorRef}
|
|
|
|
type="file"
|
|
|
|
id="customBgSelector"
|
|
|
|
onChange={handleCustomBgChange}
|
|
|
|
style={{ display: 'none' }}
|
|
|
|
accept={MIME_TYPES_ALLOWED.join(', ')}
|
|
|
|
/>
|
2024-07-19 04:24:10 +08:00
|
|
|
<div aria-hidden className="sr-only" id="vr-cam-btn-custom">
|
2022-09-30 09:09:55 +08:00
|
|
|
{intl.formatMessage(intlMessages.customDesc)}
|
2022-07-09 04:01:57 +08:00
|
|
|
</div>
|
|
|
|
</>
|
|
|
|
);
|
|
|
|
|
|
|
|
const renderNoneButton = () => (
|
|
|
|
<>
|
|
|
|
<Styled.BgNoneButton
|
2024-07-19 04:24:10 +08:00
|
|
|
icon="close"
|
2022-07-09 04:01:57 +08:00
|
|
|
label={intl.formatMessage(intlMessages.noneLabel)}
|
|
|
|
aria-pressed={currentVirtualBg?.name === undefined}
|
2024-07-19 04:24:10 +08:00
|
|
|
aria-describedby="vr-cam-btn-none"
|
2022-07-09 04:01:57 +08:00
|
|
|
hideLabel
|
|
|
|
tabIndex={disabled ? -1 : 0}
|
|
|
|
disabled={disabled}
|
|
|
|
onClick={() => _virtualBgSelected(EFFECT_TYPES.NONE_TYPE)}
|
2022-09-13 01:10:57 +08:00
|
|
|
data-test="noneBackgroundButton"
|
2022-07-09 04:01:57 +08:00
|
|
|
/>
|
2024-07-19 04:24:10 +08:00
|
|
|
<div aria-hidden className="sr-only" id="vr-cam-btn-none">
|
2022-07-09 04:01:57 +08:00
|
|
|
{intl.formatMessage(intlMessages.camBgAriaDesc, { 0: EFFECT_TYPES.NONE_TYPE })}
|
|
|
|
</div>
|
|
|
|
</>
|
|
|
|
);
|
|
|
|
|
|
|
|
const renderSkeleton = () => (
|
|
|
|
<SkeletonTheme baseColor="#DCE4EC" direction={isRTL ? 'rtl' : 'ltr'}>
|
|
|
|
{new Array(SKELETON_COUNT).fill(null).map((_, index) => (
|
|
|
|
<Styled.SkeletonWrapper key={`skeleton-${index}`}>
|
|
|
|
<Skeleton />
|
|
|
|
</Styled.SkeletonWrapper>
|
|
|
|
))}
|
|
|
|
</SkeletonTheme>
|
|
|
|
);
|
|
|
|
|
2022-07-08 23:16:37 +08:00
|
|
|
const ready = loaded && defaultSetUp;
|
2024-05-29 21:26:11 +08:00
|
|
|
const ENABLE_CAMERA_BRIGHTNESS = window.meetingClientSettings.public.app.enableCameraBrightness;
|
2022-07-08 23:16:37 +08:00
|
|
|
|
2021-07-20 04:19:06 +08:00
|
|
|
return (
|
2021-10-28 19:58:39 +08:00
|
|
|
<Styled.VirtualBackgroundRowThumbnail>
|
|
|
|
<Styled.BgWrapper
|
2021-09-14 09:50:24 +08:00
|
|
|
role="group"
|
|
|
|
aria-label={intl.formatMessage(intlMessages.virtualBackgroundSettingsLabel)}
|
2022-08-26 22:50:46 +08:00
|
|
|
brightnessEnabled={ENABLE_CAMERA_BRIGHTNESS}
|
2023-02-22 02:28:53 +08:00
|
|
|
data-test="virtualBackground"
|
2021-09-14 09:50:24 +08:00
|
|
|
>
|
2024-06-14 21:30:48 +08:00
|
|
|
{shouldEnableBackgroundUpload(isCustomVirtualBackgroundsEnabled) && (
|
2022-07-09 04:01:57 +08:00
|
|
|
<>
|
|
|
|
{!ready && renderSkeleton()}
|
|
|
|
|
|
|
|
{ready && (
|
|
|
|
<>
|
|
|
|
{renderNoneButton()}
|
|
|
|
|
|
|
|
{Object.values(backgrounds)
|
|
|
|
.sort((a, b) => b.lastActivityDate - a.lastActivityDate)
|
|
|
|
.map((background, index) => {
|
2022-07-16 04:16:33 +08:00
|
|
|
if (background.custom !== false) {
|
2022-07-09 04:01:57 +08:00
|
|
|
return renderCustomButton(background, index);
|
|
|
|
}
|
2024-07-19 04:24:10 +08:00
|
|
|
const isBlur = background.uniqueId.includes('Blur');
|
|
|
|
return isBlur ? renderBlurButton(index) : renderDefaultButton(background.uniqueId, index);
|
2022-07-09 04:01:57 +08:00
|
|
|
})}
|
|
|
|
|
|
|
|
{renderInputButton()}
|
|
|
|
</>
|
|
|
|
)}
|
|
|
|
</>
|
2022-07-07 03:03:55 +08:00
|
|
|
)}
|
2021-08-31 03:56:29 +08:00
|
|
|
|
2024-06-14 21:30:48 +08:00
|
|
|
{!shouldEnableBackgroundUpload(isCustomVirtualBackgroundsEnabled) && (
|
2022-07-07 03:03:55 +08:00
|
|
|
<>
|
2022-07-09 04:01:57 +08:00
|
|
|
{renderNoneButton()}
|
|
|
|
|
|
|
|
{renderBlurButton(0)}
|
|
|
|
|
|
|
|
{IMAGE_NAMES.map((imageName, index) => {
|
|
|
|
const actualIndex = index + 1;
|
|
|
|
return renderDefaultButton(imageName, actualIndex);
|
|
|
|
})}
|
2022-04-12 01:09:13 +08:00
|
|
|
</>
|
|
|
|
)}
|
2021-10-28 19:58:39 +08:00
|
|
|
</Styled.BgWrapper>
|
|
|
|
</Styled.VirtualBackgroundRowThumbnail>
|
2021-07-20 04:19:06 +08:00
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
const renderSelector = () => {
|
|
|
|
if (showThumbnails) return renderThumbnailSelector();
|
|
|
|
return renderDropdownSelector();
|
|
|
|
};
|
|
|
|
|
|
|
|
return (
|
2021-08-04 03:24:08 +08:00
|
|
|
<>
|
2024-06-15 01:31:27 +08:00
|
|
|
<Styled.Label>
|
|
|
|
{intl.formatMessage(
|
|
|
|
isVirtualBackgroundSupported()
|
|
|
|
? intlMessages.virtualBackgroundSettingsLabel
|
|
|
|
: intlMessages.virtualBackgroundSettingsDisabledLabel,
|
|
|
|
)}
|
|
|
|
</Styled.Label>
|
|
|
|
|
|
|
|
{renderSelector()}
|
2021-08-04 03:24:08 +08:00
|
|
|
</>
|
2021-07-20 04:19:06 +08:00
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
VirtualBgSelector.propTypes = propTypes;
|
|
|
|
|
2022-07-06 21:38:40 +08:00
|
|
|
export default injectIntl(withFileReader(VirtualBgSelector, MIME_TYPES_ALLOWED, MAX_FILE_SIZE));
|