Переглянути джерело

fix(recording): Respect the selected recording service.

j8
Hristo Terezov 6 роки тому
джерело
коміт
a6719896a2

+ 50
- 4
react/features/recording/components/Recording/AbstractStartRecordingDialog.js Переглянути файл

64
      */
64
      */
65
     isValidating: boolean,
65
     isValidating: boolean,
66
 
66
 
67
+    /**
68
+     * The currently selected recording service of type: RECORDING_TYPES.
69
+     */
70
+    selectedRecordingService: ?string,
71
+
67
     /**
72
     /**
68
      * Number of MiB of available space in user's Dropbox account.
73
      * Number of MiB of available space in user's Dropbox account.
69
      */
74
      */
89
 
94
 
90
         // Bind event handler so it is only bound once for every instance.
95
         // Bind event handler so it is only bound once for every instance.
91
         this._onSubmit = this._onSubmit.bind(this);
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
         this.state = {
111
         this.state = {
94
             isTokenValid: false,
112
             isTokenValid: false,
95
             isValidating: false,
113
             isValidating: false,
96
             userName: undefined,
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
         }
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
      * Validates the dropbox access token and fetches account information.
171
      * Validates the dropbox access token and fetches account information.
129
      *
172
      *
176
         let appData;
219
         let appData;
177
         const attributes = {};
220
         const attributes = {};
178
 
221
 
179
-        if (_isDropboxEnabled && _token) {
222
+        if (_isDropboxEnabled
223
+                && _token
224
+                && this.state.selectedRecordingService
225
+                    === RECORDING_TYPES.DROPBOX) {
180
             appData = JSON.stringify({
226
             appData = JSON.stringify({
181
                 'file_recording_metadata': {
227
                 'file_recording_metadata': {
182
                     'upload_credentials': {
228
                     'upload_credentials': {

+ 32
- 32
react/features/recording/components/Recording/StartRecordingDialogContent.js Переглянути файл

64
      */
64
      */
65
     isValidating: boolean,
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
      * Number of MiB of available space in user's Dropbox account.
79
      * Number of MiB of available space in user's Dropbox account.
69
      */
80
      */
77
     /**
88
     /**
78
      * The display name of the user's Dropbox account.
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
  * React Component for getting confirmation to start a file recording session.
95
  * React Component for getting confirmation to start a file recording session.
97
  *
96
  *
98
  * @extends Component
97
  * @extends Component
99
  */
98
  */
100
-class StartRecordingDialogContent extends Component<Props, State> {
99
+class StartRecordingDialogContent extends Component<Props> {
101
     /**
100
     /**
102
      * Initializes a new {@code StartRecordingDialogContent} instance.
101
      * Initializes a new {@code StartRecordingDialogContent} instance.
103
      *
102
      *
113
             = this._onDropboxSwitchChange.bind(this);
112
             = this._onDropboxSwitchChange.bind(this);
114
         this._onRecordingServiceSwitchChange
113
         this._onRecordingServiceSwitchChange
115
             = this._onRecordingServiceSwitchChange.bind(this);
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
                         style = { styles.switch }
158
                         style = { styles.switch }
166
                         trackColor = {{ false: ColorPalette.lightGrey }}
159
                         trackColor = {{ false: ColorPalette.lightGrey }}
167
                         value = {
160
                         value = {
168
-                            this.state.selectedRecordingService
161
+                            this.props.selectedRecordingService
169
                                 === RECORDING_TYPES.JITSI_REC_SERVICE } />
162
                                 === RECORDING_TYPES.JITSI_REC_SERVICE } />
170
                 ) : null;
163
                 ) : null;
171
 
164
 
243
                     onValueChange = { this._onDropboxSwitchChange }
236
                     onValueChange = { this._onDropboxSwitchChange }
244
                     style = { styles.switch }
237
                     style = { styles.switch }
245
                     trackColor = {{ false: ColorPalette.lightGrey }}
238
                     trackColor = {{ false: ColorPalette.lightGrey }}
246
-                    value = { this.state.selectedRecordingService
239
+                    value = { this.props.selectedRecordingService
247
                         === RECORDING_TYPES.DROPBOX } />
240
                         === RECORDING_TYPES.DROPBOX } />
248
             );
241
             );
249
         }
242
         }
287
      * @returns {void}
280
      * @returns {void}
288
      */
281
      */
289
     _onRecordingServiceSwitchChange() {
282
     _onRecordingServiceSwitchChange() {
283
+        const {
284
+            isTokenValid,
285
+            onChange,
286
+            selectedRecordingService
287
+        } = this.props;
290
 
288
 
291
         // act like group, cannot toggle off
289
         // act like group, cannot toggle off
292
-        if (this.state.selectedRecordingService
290
+        if (selectedRecordingService
293
                 === RECORDING_TYPES.JITSI_REC_SERVICE) {
291
                 === RECORDING_TYPES.JITSI_REC_SERVICE) {
294
             return;
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
             this._onSignOut();
298
             this._onSignOut();
303
         }
299
         }
304
     }
300
     }
309
      * @returns {void}
305
      * @returns {void}
310
      */
306
      */
311
     _onDropboxSwitchChange() {
307
     _onDropboxSwitchChange() {
308
+        const {
309
+            isTokenValid,
310
+            onChange,
311
+            selectedRecordingService
312
+        } = this.props;
313
+
312
         // act like group, cannot toggle off
314
         // act like group, cannot toggle off
313
-        if (this.state.selectedRecordingService
315
+        if (selectedRecordingService
314
                 === RECORDING_TYPES.DROPBOX) {
316
                 === RECORDING_TYPES.DROPBOX) {
315
             return;
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
             this._onSignIn();
323
             this._onSignIn();
324
         }
324
         }
325
     }
325
     }

+ 12
- 2
react/features/recording/components/Recording/native/StartRecordingDialog.js Переглянути файл

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

+ 13
- 3
react/features/recording/components/Recording/web/StartRecordingDialog.js Переглянути файл

24
      * @inheritdoc
24
      * @inheritdoc
25
      */
25
      */
26
     render() {
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
         const { _fileRecordingsServiceEnabled, _isDropboxEnabled } = this.props;
34
         const { _fileRecordingsServiceEnabled, _isDropboxEnabled } = this.props;
29
 
35
 
30
         // disable ok button id recording service is shown only, when
36
         // disable ok button id recording service is shown only, when
45
                 <StartRecordingDialogContent
51
                 <StartRecordingDialogContent
46
                     fileRecordingsServiceEnabled
52
                     fileRecordingsServiceEnabled
47
                         = { _fileRecordingsServiceEnabled }
53
                         = { _fileRecordingsServiceEnabled }
48
-                    integrationsEnabled = { _isDropboxEnabled }
54
+                    integrationsEnabled = { this._areIntegrationsEnabled() }
49
                     isTokenValid = { isTokenValid }
55
                     isTokenValid = { isTokenValid }
50
                     isValidating = { isValidating }
56
                     isValidating = { isValidating }
57
+                    onChange = { this._onSelectedRecordingServiceChanged }
58
+                    selectedRecordingService = { selectedRecordingService }
51
                     spaceLeft = { spaceLeft }
59
                     spaceLeft = { spaceLeft }
52
                     userName = { userName } />
60
                     userName = { userName } />
53
             </Dialog>
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
 export default translate(connect(mapStateToProps)(StartRecordingDialog));
70
 export default translate(connect(mapStateToProps)(StartRecordingDialog));

Завантаження…
Відмінити
Зберегти