瀏覽代碼

fix(virtual-background): Prevent virtual background selection if it h… (#9414)

Co-authored-by: tudordan7 <tudor.pop@decagon.tech>
j8
Tudor D. Pop 3 年之前
父節點
當前提交
dc776d209c
No account linked to committer's email address
共有 1 個文件被更改,包括 21 次插入6 次删除
  1. 21
    6
      react/features/virtual-background/components/VirtualBackgroundDialog.js

+ 21
- 6
react/features/virtual-background/components/VirtualBackgroundDialog.js 查看文件

83
     _selectedThumbnail: string,
83
     _selectedThumbnail: string,
84
 
84
 
85
     /**
85
     /**
86
-     * Returns the selected virtual source object.
86
+     * Returns the selected virtual background object.
87
      */
87
      */
88
-    _virtualSource: Object,
88
+    _virtualBackground: Object,
89
 
89
 
90
     /**
90
     /**
91
      * The redux {@code dispatch} function.
91
      * The redux {@code dispatch} function.
107
  *
107
  *
108
  * @returns {ReactElement}
108
  * @returns {ReactElement}
109
  */
109
  */
110
-function VirtualBackground({ _jitsiTrack, _selectedThumbnail, _virtualSource, dispatch, t }: Props) {
110
+function VirtualBackground({ _jitsiTrack, _selectedThumbnail, _virtualBackground, dispatch, t }: Props) {
111
     const [ options, setOptions ] = useState({});
111
     const [ options, setOptions ] = useState({});
112
     const localImages = jitsiLocalStorage.getItem('virtualBackgrounds');
112
     const localImages = jitsiLocalStorage.getItem('virtualBackgrounds');
113
     const [ storedImages, setStoredImages ] = useState<Array<Image>>((localImages && Bourne.parse(localImages)) || []);
113
     const [ storedImages, setStoredImages ] = useState<Array<Image>>((localImages && Bourne.parse(localImages)) || []);
114
     const [ loading, setLoading ] = useState(false);
114
     const [ loading, setLoading ] = useState(false);
115
     const uploadImageButton: Object = useRef(null);
115
     const uploadImageButton: Object = useRef(null);
116
-    const [ activeDesktopVideo ] = useState(_virtualSource?.videoType === VIDEO_TYPE.DESKTOP ? _virtualSource : null);
117
-
116
+    const [ activeDesktopVideo ] = useState(_virtualBackground?.virtualSource?.videoType === VIDEO_TYPE.DESKTOP
117
+        ? _virtualBackground.virtualSource
118
+        : null);
119
+    const [ initialVirtualBackground ] = useState(_virtualBackground);
118
     const deleteStoredImage = useCallback(e => {
120
     const deleteStoredImage = useCallback(e => {
119
         const imageId = e.currentTarget.getAttribute('data-imageid');
121
         const imageId = e.currentTarget.getAttribute('data-imageid');
120
 
122
 
308
         dispatch(hideDialog());
310
         dispatch(hideDialog());
309
     }, [ dispatch, options ]);
311
     }, [ dispatch, options ]);
310
 
312
 
313
+    // Prevent the selection of a new virtual background if it has not been applied by default
314
+    const cancelVirtualBackground = useCallback(async () => {
315
+        await setOptions({
316
+            backgroundType: initialVirtualBackground.backgroundType,
317
+            enabled: initialVirtualBackground.backgroundEffectEnabled,
318
+            url: initialVirtualBackground.virtualSource,
319
+            selectedThumbnail: initialVirtualBackground.selectedThumbnail,
320
+            blurValue: initialVirtualBackground.blurValue
321
+        });
322
+        dispatch(hideDialog());
323
+    });
324
+
311
     return (
325
     return (
312
         <Dialog
326
         <Dialog
313
             hideCancelButton = { false }
327
             hideCancelButton = { false }
314
             okKey = { 'virtualBackground.apply' }
328
             okKey = { 'virtualBackground.apply' }
329
+            onCancel = { cancelVirtualBackground }
315
             onSubmit = { applyVirtualBackground }
330
             onSubmit = { applyVirtualBackground }
316
             submitDisabled = { !options || loading }
331
             submitDisabled = { !options || loading }
317
             titleKey = { 'virtualBackground.title' } >
332
             titleKey = { 'virtualBackground.title' } >
478
  */
493
  */
479
 function _mapStateToProps(state): Object {
494
 function _mapStateToProps(state): Object {
480
     return {
495
     return {
481
-        _virtualSource: state['features/virtual-background'].virtualSource,
496
+        _virtualBackground: state['features/virtual-background'],
482
         _selectedThumbnail: state['features/virtual-background'].selectedThumbnail,
497
         _selectedThumbnail: state['features/virtual-background'].selectedThumbnail,
483
         _jitsiTrack: getLocalVideoTrack(state['features/base/tracks'])?.jitsiTrack
498
         _jitsiTrack: getLocalVideoTrack(state['features/base/tracks'])?.jitsiTrack
484
     };
499
     };

Loading…
取消
儲存