Browse Source

don't use params to switch actionType

master
Radium Zheng 7 years ago
parent
commit
337cea6488

+ 21
- 10
react/features/local-recording/actions.js View File

@@ -7,24 +7,35 @@ import {
7 7
     LOCAL_RECORDING_STATS_UPDATE
8 8
 } from './actionTypes';
9 9
 
10
+// The following two actions signal state changes in local recording engagement.
11
+// In other words, the events of the local WebWorker / MediaRecorder starting to
12
+// record and finishing recording.
13
+// Note that this is not the event fired when the users tries to start the
14
+// recording in the UI.
15
+
10 16
 /**
11
- * Signals state change in local recording engagement.
12
- * In other words, the events of the local WebWorker / MediaRecorder
13
- * starting to record and finishing recording.
14
- *
15
- * Note that this is not the event fired when the users tries to start
16
- * the recording in the UI.
17
+ * Signals that local recording has started.
17 18
  *
18
- * @param {bool} isEngaged - Whether local recording is engaged or not.
19 19
  * @returns {{
20 20
  *     type: LOCAL_RECORDING_ENGAGED
21
- * }|{
21
+ * }}
22
+ */
23
+export function localRecordingEngaged() {
24
+    return {
25
+        type: LOCAL_RECORDING_ENGAGED
26
+    };
27
+}
28
+
29
+/**
30
+ * Signals that local recording has finished.
31
+ *
32
+ * @returns {{
22 33
  *     type: LOCAL_RECORDING_UNENGAGED
23 34
  * }}
24 35
  */
25
-export function signalLocalRecordingEngagement(isEngaged: boolean) {
36
+export function localRecordingUnengaged() {
26 37
     return {
27
-        type: isEngaged ? LOCAL_RECORDING_ENGAGED : LOCAL_RECORDING_UNENGAGED
38
+        type: LOCAL_RECORDING_UNENGAGED
28 39
     };
29 40
 }
30 41
 

+ 9
- 5
react/features/local-recording/middleware.js View File

@@ -6,8 +6,8 @@ import { i18next } from '../base/i18n';
6 6
 import { MiddlewareRegistry } from '../base/redux';
7 7
 import { showNotification } from '../notifications';
8 8
 
9
+import { localRecordingEngaged, localRecordingUnengaged } from './actions';
9 10
 import { recordingController } from './controller';
10
-import { signalLocalRecordingEngagement } from './actions';
11 11
 
12 12
 MiddlewareRegistry.register(({ getState, dispatch }) => next => action => {
13 13
     const result = next(action);
@@ -20,10 +20,14 @@ MiddlewareRegistry.register(({ getState, dispatch }) => next => action => {
20 20
         break;
21 21
     }
22 22
     case APP_WILL_MOUNT:
23
-        // realize the delegates on recordingController,
24
-        // providing UI reactions.
25
-        recordingController.onStateChanged = function(state) {
26
-            dispatch(signalLocalRecordingEngagement(state));
23
+        // realize the delegates on recordingController, allowing the UI to
24
+        // react to state changes in recordingController.
25
+        recordingController.onStateChanged = function(isEngaged) {
26
+            if (isEngaged) {
27
+                dispatch(localRecordingEngaged());
28
+            } else {
29
+                dispatch(localRecordingUnengaged());
30
+            }
27 31
         };
28 32
 
29 33
         recordingController.onWarning = function(message) {

Loading…
Cancel
Save