Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.
TypeScript debiandeep-videojitsijitsi-meetscalable-video-conferencessfuvideovideo-communicationvideo-conferencingwebrtc
fix(virtual-background) standardize options object (#13760)
Mihaela Dumitru9d68cb52b3ea
diff --git a/react/features/settings/components/web/SettingsDialog.tsx b/react/features/settings/components/web/SettingsDialog.tsxindex edfe81bb7a..8bbd4d83ad 100644--- a/react/features/settings/components/web/SettingsDialog.tsx+++ b/react/features/settings/components/web/SettingsDialog.tsx@@ -212,15 +212,7 @@ function _mapStateToProps(state: IReduxState, ownProps: any) {cancel: () => {const { options } = getVirtualBackgroundTabProps(state, isDisplayedOnWelcomePage);- return submitVirtualBackgroundTab({- options: {- backgroundType: options.backgroundType,- enabled: options.backgroundEffectEnabled,- url: options.virtualSource,- selectedThumbnail: options.selectedThumbnail,- blurValue: options.blurValue- }- }, true);+ return submitVirtualBackgroundTab({ options }, true);},icon: IconImage});diff --git a/react/features/virtual-background/actions.ts b/react/features/virtual-background/actions.tsindex e3533a9206..18d2ac845f 100644--- a/react/features/virtual-background/actions.ts+++ b/react/features/virtual-background/actions.ts@@ -3,7 +3,7 @@ import { createVirtualBackgroundEffect } from '../stream-effects/virtual-backgroimport { BACKGROUND_ENABLED, SET_VIRTUAL_BACKGROUND } from './actionTypes';import logger from './logger';-import { IVirtualBackgroundOptions } from './types';+import { IVirtualBackground } from './reducer';/*** Signals the local participant activate the virtual background video or not.@@ -12,16 +12,16 @@ import { IVirtualBackgroundOptions } from './types';* @param {Object} jitsiTrack - Represents the jitsi track that will have backgraund effect applied.* @returns {Promise}*/-export function toggleBackgroundEffect(options: IVirtualBackgroundOptions, jitsiTrack: any) {+export function toggleBackgroundEffect(options: IVirtualBackground, jitsiTrack: any) {return async function(dispatch: IStore['dispatch'], getState: IStore['getState']) {- await dispatch(backgroundEnabled(options.enabled));+ await dispatch(backgroundEnabled(options.backgroundEffectEnabled));await dispatch(setVirtualBackground(options));const state = getState();const virtualBackground = state['features/virtual-background'];if (jitsiTrack) {try {- if (options.enabled) {+ if (options.backgroundEffectEnabled) {await jitsiTrack.setEffect(await createVirtualBackgroundEffect(virtualBackground, dispatch));} else {await jitsiTrack.setEffect(undefined);@@ -46,10 +46,10 @@ export function toggleBackgroundEffect(options: IVirtualBackgroundOptions, jitsi* type: string,* }}*/-export function setVirtualBackground(options?: IVirtualBackgroundOptions) {+export function setVirtualBackground(options?: IVirtualBackground) {return {type: SET_VIRTUAL_BACKGROUND,- virtualSource: options?.url,+ virtualSource: options?.virtualSource,blurValue: options?.blurValue,backgroundType: options?.backgroundType,selectedThumbnail: options?.selectedThumbnail@@ -65,7 +65,7 @@ export function setVirtualBackground(options?: IVirtualBackgroundOptions) {* backgroundEffectEnabled: boolean* }}*/-export function backgroundEnabled(backgroundEffectEnabled: boolean) {+export function backgroundEnabled(backgroundEffectEnabled?: boolean) {return {type: BACKGROUND_ENABLED,backgroundEffectEnableddiff --git a/react/features/virtual-background/components/UploadImageButton.tsx b/react/features/virtual-background/components/UploadImageButton.tsxindex 8de48e6d6b..917dd55ee6 100644--- a/react/features/virtual-background/components/UploadImageButton.tsx+++ b/react/features/virtual-background/components/UploadImageButton.tsx@@ -105,10 +105,10 @@ function UploadImageButton({}]);setOptions({+ backgroundEffectEnabled: true,backgroundType: VIRTUAL_BACKGROUND_TYPE.IMAGE,- enabled: true,- url,- selectedThumbnail: uuId+ selectedThumbnail: uuId,+ virtualSource: url});};logger.info('New virtual background image uploaded!');diff --git a/react/features/virtual-background/components/VirtualBackgroundPreview.tsx b/react/features/virtual-background/components/VirtualBackgroundPreview.tsxindex 315757bc70..3ff8ae444d 100644--- a/react/features/virtual-background/components/VirtualBackgroundPreview.tsx+++ b/react/features/virtual-background/components/VirtualBackgroundPreview.tsx@@ -15,6 +15,7 @@ import { showWarningNotification } from '../../notifications/actions';import { NOTIFICATION_TIMEOUT_TYPE } from '../../notifications/constants';import { toggleBackgroundEffect } from '../actions';import logger from '../logger';+import { IVirtualBackground } from '../reducer';/*** The type of the React {@code PureComponent} props of {@link VirtualBackgroundPreview}.@@ -39,7 +40,7 @@ export interface IProps extends WithTranslation {/*** Represents the virtual background set options.*/- options: any;+ options: IVirtualBackground;/*** The id of the selected video device.diff --git a/react/features/virtual-background/components/VirtualBackgrounds.tsx b/react/features/virtual-background/components/VirtualBackgrounds.tsxindex 3e20faef5a..6c852832d5 100644--- a/react/features/virtual-background/components/VirtualBackgrounds.tsx+++ b/react/features/virtual-background/components/VirtualBackgrounds.tsx@@ -19,6 +19,7 @@ import Spinner from '../../base/ui/components/web/Spinner';import { BACKGROUNDS_LIMIT, IMAGES, type Image, VIRTUAL_BACKGROUND_TYPE } from '../constants';import { toDataURL } from '../functions';import logger from '../logger';+import { IVirtualBackground } from '../reducer';import UploadImageButton from './UploadImageButton';import VirtualBackgroundPreview from './VirtualBackgroundPreview';@@ -72,7 +73,7 @@ interface IProps extends WithTranslation {/*** Virtual background options.*/- options: any;+ options: IVirtualBackground;/*** Returns the selected thumbnail identifier.@@ -254,8 +255,8 @@ function VirtualBackgrounds({const enableBlur = useCallback(async () => {onOptionsChange({+ backgroundEffectEnabled: true,backgroundType: VIRTUAL_BACKGROUND_TYPE.BLUR,- enabled: true,blurValue: 25,selectedThumbnail: 'blur'});@@ -272,8 +273,8 @@ function VirtualBackgrounds({const enableSlideBlur = useCallback(async () => {onOptionsChange({+ backgroundEffectEnabled: true,backgroundType: VIRTUAL_BACKGROUND_TYPE.BLUR,- enabled: true,blurValue: 8,selectedThumbnail: 'slight-blur'});@@ -290,7 +291,7 @@ function VirtualBackgrounds({const removeBackground = useCallback(async () => {onOptionsChange({- enabled: false,+ backgroundEffectEnabled: false,selectedThumbnail: 'none'});logger.info('"None" option set for virtual background preview!');@@ -310,10 +311,10 @@ function VirtualBackgrounds({if (image) {onOptionsChange({- backgroundType: 'image',- enabled: true,- url: image.src,- selectedThumbnail: image.id+ backgroundEffectEnabled: true,+ backgroundType: VIRTUAL_BACKGROUND_TYPE.IMAGE,+ selectedThumbnail: image.id,+ virtualSource: image.src});logger.info('Uploaded image set for virtual background preview!');}@@ -328,10 +329,10 @@ function VirtualBackgrounds({const url = await toDataURL(image.src);onOptionsChange({- backgroundType: 'image',- enabled: true,- url,- selectedThumbnail: image.id+ backgroundEffectEnabled: true,+ backgroundType: VIRTUAL_BACKGROUND_TYPE.IMAGE,+ selectedThumbnail: image.id,+ virtualSource: url});logger.info('Image set for virtual background preview!');} catch (err) {diff --git a/react/features/virtual-background/types.ts b/react/features/virtual-background/types.tsdeleted file mode 100644index 6f2c5b013b..0000000000--- a/react/features/virtual-background/types.ts+++ /dev/null@@ -1,6 +0,0 @@-import { IVirtualBackground } from './reducer';--export interface IVirtualBackgroundOptions extends IVirtualBackground {- enabled: boolean;- url?: string;-}