浏览代码

fix(recording): Respect the selected recording service.

j8
Hristo Terezov 6 年前
父节点
当前提交
a6719896a2

+ 50
- 4
react/features/recording/components/Recording/AbstractStartRecordingDialog.js 查看文件

@@ -64,6 +64,11 @@ type State = {
64 64
      */
65 65
     isValidating: boolean,
66 66
 
67
+    /**
68
+     * The currently selected recording service of type: RECORDING_TYPES.
69
+     */
70
+    selectedRecordingService: ?string,
71
+
67 72
     /**
68 73
      * Number of MiB of available space in user's Dropbox account.
69 74
      */
@@ -89,15 +94,27 @@ class AbstractStartRecordingDialog extends Component<Props, State> {
89 94
 
90 95
         // Bind event handler so it is only bound once for every instance.
91 96
         this._onSubmit = this._onSubmit.bind(this);
97
+        this._onSelectedRecordingServiceChanged
98
+            = this._onSelectedRecordingServiceChanged.bind(this);
99
+
100
+        let selectedRecordingService;
101
+
102
+        // TODO: Potentially check if we need to handle changes of
103
+        // _fileRecordingsServiceEnabled and _areIntegrationsEnabled()
104
+        if (this.props._fileRecordingsServiceEnabled
105
+                || !this._areIntegrationsEnabled()) {
106
+            selectedRecordingService = RECORDING_TYPES.JITSI_REC_SERVICE;
107
+        } else if (this._areIntegrationsEnabled()) {
108
+            selectedRecordingService = RECORDING_TYPES.DROPBOX;
109
+        }
92 110
 
93 111
         this.state = {
94 112
             isTokenValid: false,
95 113
             isValidating: false,
96 114
             userName: undefined,
97
-            spaceLeft: undefined
115
+            spaceLeft: undefined,
116
+            selectedRecordingService
98 117
         };
99
-
100
-        this._onSubmit = this._onSubmit.bind(this);
101 118
     }
102 119
 
103 120
     /**
@@ -124,6 +141,32 @@ class AbstractStartRecordingDialog extends Component<Props, State> {
124 141
         }
125 142
     }
126 143
 
144
+    _areIntegrationsEnabled: () => boolean;
145
+
146
+    /**
147
+     * Returns true if the integrations with third party services are enabled
148
+     * and false otherwise.
149
+     *
150
+     * @returns {boolean} - True if the integrations with third party services
151
+     * are enabled and false otherwise.
152
+     */
153
+    _areIntegrationsEnabled() {
154
+        return this.props._isDropboxEnabled;
155
+    }
156
+
157
+    _onSelectedRecordingServiceChanged: (string) => void;
158
+
159
+    /**
160
+     * Handles selected recording service changes.
161
+     *
162
+     * @param {string} selectedRecordingService - The new selected recording
163
+     * service.
164
+     * @returns {void}
165
+     */
166
+    _onSelectedRecordingServiceChanged(selectedRecordingService) {
167
+        this.setState({ selectedRecordingService });
168
+    }
169
+
127 170
     /**
128 171
      * Validates the dropbox access token and fetches account information.
129 172
      *
@@ -176,7 +219,10 @@ class AbstractStartRecordingDialog extends Component<Props, State> {
176 219
         let appData;
177 220
         const attributes = {};
178 221
 
179
-        if (_isDropboxEnabled && _token) {
222
+        if (_isDropboxEnabled
223
+                && _token
224
+                && this.state.selectedRecordingService
225
+                    === RECORDING_TYPES.DROPBOX) {
180 226
             appData = JSON.stringify({
181 227
                 'file_recording_metadata': {
182 228
                     'upload_credentials': {

+ 32
- 32
react/features/recording/components/Recording/StartRecordingDialogContent.js 查看文件

@@ -64,6 +64,17 @@ type Props = {
64 64
      */
65 65
     isValidating: boolean,
66 66
 
67
+    /**
68
+     * The function will be called when there are changes related to the
69
+     * switches.
70
+     */
71
+    onChange: Function,
72
+
73
+    /**
74
+     * The currently selected recording service of type: RECORDING_TYPES.
75
+     */
76
+    selectedRecordingService: ?string,
77
+
67 78
     /**
68 79
      * Number of MiB of available space in user's Dropbox account.
69 80
      */
@@ -77,27 +88,15 @@ type Props = {
77 88
     /**
78 89
      * The display name of the user's Dropbox account.
79 90
      */
80
-    userName: ?string,
81
-};
82
-
83
-/**
84
- * State of the component.
85
- */
86
-type State = {
87
-
88
-    /**
89
-     * The currently selected recording service of type: RECORDING_TYPES.
90
-     */
91
-    selectedRecordingService: string
91
+    userName: ?string
92 92
 };
93 93
 
94
-
95 94
 /**
96 95
  * React Component for getting confirmation to start a file recording session.
97 96
  *
98 97
  * @extends Component
99 98
  */
100
-class StartRecordingDialogContent extends Component<Props, State> {
99
+class StartRecordingDialogContent extends Component<Props> {
101 100
     /**
102 101
      * Initializes a new {@code StartRecordingDialogContent} instance.
103 102
      *
@@ -113,12 +112,6 @@ class StartRecordingDialogContent extends Component<Props, State> {
113 112
             = this._onDropboxSwitchChange.bind(this);
114 113
         this._onRecordingServiceSwitchChange
115 114
             = this._onRecordingServiceSwitchChange.bind(this);
116
-
117
-        // the initial state is jitsi rec service is always selected
118
-        // if only one type of recording is enabled this state will be ignored
119
-        this.state = {
120
-            selectedRecordingService: RECORDING_TYPES.JITSI_REC_SERVICE
121
-        };
122 115
     }
123 116
 
124 117
     /**
@@ -165,7 +158,7 @@ class StartRecordingDialogContent extends Component<Props, State> {
165 158
                         style = { styles.switch }
166 159
                         trackColor = {{ false: ColorPalette.lightGrey }}
167 160
                         value = {
168
-                            this.state.selectedRecordingService
161
+                            this.props.selectedRecordingService
169 162
                                 === RECORDING_TYPES.JITSI_REC_SERVICE } />
170 163
                 ) : null;
171 164
 
@@ -243,7 +236,7 @@ class StartRecordingDialogContent extends Component<Props, State> {
243 236
                     onValueChange = { this._onDropboxSwitchChange }
244 237
                     style = { styles.switch }
245 238
                     trackColor = {{ false: ColorPalette.lightGrey }}
246
-                    value = { this.state.selectedRecordingService
239
+                    value = { this.props.selectedRecordingService
247 240
                         === RECORDING_TYPES.DROPBOX } />
248 241
             );
249 242
         }
@@ -287,18 +280,21 @@ class StartRecordingDialogContent extends Component<Props, State> {
287 280
      * @returns {void}
288 281
      */
289 282
     _onRecordingServiceSwitchChange() {
283
+        const {
284
+            isTokenValid,
285
+            onChange,
286
+            selectedRecordingService
287
+        } = this.props;
290 288
 
291 289
         // act like group, cannot toggle off
292
-        if (this.state.selectedRecordingService
290
+        if (selectedRecordingService
293 291
                 === RECORDING_TYPES.JITSI_REC_SERVICE) {
294 292
             return;
295 293
         }
296 294
 
297
-        this.setState({
298
-            selectedRecordingService: RECORDING_TYPES.JITSI_REC_SERVICE
299
-        });
295
+        onChange(RECORDING_TYPES.JITSI_REC_SERVICE);
300 296
 
301
-        if (this.props.isTokenValid) {
297
+        if (isTokenValid) {
302 298
             this._onSignOut();
303 299
         }
304 300
     }
@@ -309,17 +305,21 @@ class StartRecordingDialogContent extends Component<Props, State> {
309 305
      * @returns {void}
310 306
      */
311 307
     _onDropboxSwitchChange() {
308
+        const {
309
+            isTokenValid,
310
+            onChange,
311
+            selectedRecordingService
312
+        } = this.props;
313
+
312 314
         // act like group, cannot toggle off
313
-        if (this.state.selectedRecordingService
315
+        if (selectedRecordingService
314 316
                 === RECORDING_TYPES.DROPBOX) {
315 317
             return;
316 318
         }
317 319
 
318
-        this.setState({
319
-            selectedRecordingService: RECORDING_TYPES.DROPBOX
320
-        });
320
+        onChange(RECORDING_TYPES.DROPBOX);
321 321
 
322
-        if (!this.props.isTokenValid) {
322
+        if (!isTokenValid) {
323 323
             this._onSignIn();
324 324
         }
325 325
     }

+ 12
- 2
react/features/recording/components/Recording/native/StartRecordingDialog.js 查看文件

@@ -24,7 +24,13 @@ class StartRecordingDialog extends AbstractStartRecordingDialog {
24 24
      * @inheritdoc
25 25
      */
26 26
     render() {
27
-        const { isTokenValid, isValidating, spaceLeft, userName } = this.state;
27
+        const {
28
+            isTokenValid,
29
+            isValidating,
30
+            selectedRecordingService,
31
+            spaceLeft,
32
+            userName
33
+        } = this.state;
28 34
         const { _fileRecordingsServiceEnabled, _isDropboxEnabled } = this.props;
29 35
 
30 36
         // disable ok button id recording service is shown only, when
@@ -42,16 +48,20 @@ class StartRecordingDialog extends AbstractStartRecordingDialog {
42 48
                 <StartRecordingDialogContent
43 49
                     fileRecordingsServiceEnabled
44 50
                         = { _fileRecordingsServiceEnabled }
45
-                    integrationsEnabled = { _isDropboxEnabled }
51
+                    integrationsEnabled = { this._areIntegrationsEnabled() }
46 52
                     isTokenValid = { isTokenValid }
47 53
                     isValidating = { isValidating }
54
+                    onChange = { this._onSelectedRecordingServiceChanged }
55
+                    selectedRecordingService = { selectedRecordingService }
48 56
                     spaceLeft = { spaceLeft }
49 57
                     userName = { userName } />
50 58
             </CustomSubmitDialog>
51 59
         );
52 60
     }
53 61
 
62
+    _areIntegrationsEnabled: () => boolean;
54 63
     _onSubmit: () => boolean
64
+    _onSelectedRecordingServiceChanged: (string) => void;
55 65
 }
56 66
 
57 67
 export default translate(connect(mapStateToProps)(StartRecordingDialog));

+ 13
- 3
react/features/recording/components/Recording/web/StartRecordingDialog.js 查看文件

@@ -24,7 +24,13 @@ class StartRecordingDialog extends AbstractStartRecordingDialog {
24 24
      * @inheritdoc
25 25
      */
26 26
     render() {
27
-        const { isTokenValid, isValidating, spaceLeft, userName } = this.state;
27
+        const {
28
+            isTokenValid,
29
+            isValidating,
30
+            selectedRecordingService,
31
+            spaceLeft,
32
+            userName
33
+        } = this.state;
28 34
         const { _fileRecordingsServiceEnabled, _isDropboxEnabled } = this.props;
29 35
 
30 36
         // disable ok button id recording service is shown only, when
@@ -45,16 +51,20 @@ class StartRecordingDialog extends AbstractStartRecordingDialog {
45 51
                 <StartRecordingDialogContent
46 52
                     fileRecordingsServiceEnabled
47 53
                         = { _fileRecordingsServiceEnabled }
48
-                    integrationsEnabled = { _isDropboxEnabled }
54
+                    integrationsEnabled = { this._areIntegrationsEnabled() }
49 55
                     isTokenValid = { isTokenValid }
50 56
                     isValidating = { isValidating }
57
+                    onChange = { this._onSelectedRecordingServiceChanged }
58
+                    selectedRecordingService = { selectedRecordingService }
51 59
                     spaceLeft = { spaceLeft }
52 60
                     userName = { userName } />
53 61
             </Dialog>
54 62
         );
55 63
     }
56 64
 
57
-    _onSubmit: () => boolean
65
+    _areIntegrationsEnabled: () => boolean;
66
+    _onSubmit: () => boolean;
67
+    _onSelectedRecordingServiceChanged: (string) => void;
58 68
 }
59 69
 
60 70
 export default translate(connect(mapStateToProps)(StartRecordingDialog));

正在加载...
取消
保存