Explorar el Código

reducer should be a pure function

master
Radium Zheng hace 7 años
padre
commit
0f3b67e53e

+ 6
- 4
react/features/local-recording/actionTypes.js Ver fichero

@@ -3,7 +3,8 @@
3 3
  * (as in: {@code RecordingAdapter} is actively collecting audio data).
4 4
  *
5 5
  * {
6
- *     type: LOCAL_RECORDING_ENGAGED
6
+ *     type: LOCAL_RECORDING_ENGAGED,
7
+ *     recordingEngagedAt: Date
7 8
  * }
8 9
  */
9 10
 export const LOCAL_RECORDING_ENGAGED = Symbol('LOCAL_RECORDING_ENGAGED');
@@ -29,11 +30,12 @@ export const LOCAL_RECORDING_TOGGLE_DIALOG
29 30
     = Symbol('LOCAL_RECORDING_TOGGLE_DIALOG');
30 31
 
31 32
 /**
32
- * Action to update {@code LocalRecordingInfoDialog} with stats
33
- * from all clients.
33
+ * Action to update {@code LocalRecordingInfoDialog} with stats from all
34
+ * clients.
34 35
  *
35 36
  * {
36
- *     type: LOCAL_RECORDING_STATS_UPDATE
37
+ *     type: LOCAL_RECORDING_STATS_UPDATE,
38
+ *     stats: Object
37 39
  * }
38 40
  */
39 41
 export const LOCAL_RECORDING_STATS_UPDATE

+ 7
- 4
react/features/local-recording/actions.js Ver fichero

@@ -14,15 +14,18 @@ import {
14 14
 // recording in the UI.
15 15
 
16 16
 /**
17
- * Signals that local recording has started.
17
+ * Signals that local recording has been engaged.
18 18
  *
19
+ * @param {Date} startTime - Time when the recording is engaged.
19 20
  * @returns {{
20
- *     type: LOCAL_RECORDING_ENGAGED
21
+ *     type: LOCAL_RECORDING_ENGAGED,
22
+ *     recordingEngagedAt: Date
21 23
  * }}
22 24
  */
23
-export function localRecordingEngaged() {
25
+export function localRecordingEngaged(startTime: Date) {
24 26
     return {
25
-        type: LOCAL_RECORDING_ENGAGED
27
+        type: LOCAL_RECORDING_ENGAGED,
28
+        recordingEngagedAt: startTime
26 29
     };
27 30
 }
28 31
 

+ 6
- 6
react/features/local-recording/components/LocalRecordingInfoDialog.js Ver fichero

@@ -44,7 +44,7 @@ type Props = {
44 44
      * The start time of the current local recording session.
45 45
      * Used to calculate the duration of recording.
46 46
      */
47
-    recordingStartedAt: Date,
47
+    recordingEngagedAt: Date,
48 48
 
49 49
     /**
50 50
      * Stats of all the participant.
@@ -103,11 +103,11 @@ class LocalRecordingInfoDialog extends Component<Props, State> {
103 103
         this._timer = setInterval(
104 104
             () => {
105 105
                 this.setState((_prevState, props) => {
106
-                    const nowTime = new Date(Date.now());
106
+                    const nowTime = new Date();
107 107
 
108 108
                     return {
109 109
                         durationString: this._getDuration(nowTime,
110
-                            props.recordingStartedAt)
110
+                            props.recordingEngagedAt)
111 111
                     };
112 112
                 });
113 113
                 try {
@@ -312,7 +312,7 @@ class LocalRecordingInfoDialog extends Component<Props, State> {
312 312
  *     encodingFormat: string,
313 313
  *     isModerator: boolean,
314 314
  *     isOn: boolean,
315
- *     recordingStartedAt: Date,
315
+ *     recordingEngagedAt: Date,
316 316
  *     stats: Object
317 317
  * }}
318 318
  */
@@ -320,7 +320,7 @@ function _mapStateToProps(state) {
320 320
     const {
321 321
         encodingFormat,
322 322
         isEngaged: isOn,
323
-        recordingStartedAt,
323
+        recordingEngagedAt,
324 324
         stats
325 325
     } = state['features/local-recording'];
326 326
     const isModerator
@@ -330,7 +330,7 @@ function _mapStateToProps(state) {
330 330
         encodingFormat,
331 331
         isModerator,
332 332
         isOn,
333
-        recordingStartedAt,
333
+        recordingEngagedAt,
334 334
         stats
335 335
     };
336 336
 }

+ 3
- 1
react/features/local-recording/middleware.js Ver fichero

@@ -24,7 +24,9 @@ MiddlewareRegistry.register(({ getState, dispatch }) => next => action => {
24 24
         // react to state changes in recordingController.
25 25
         recordingController.onStateChanged = function(isEngaged) {
26 26
             if (isEngaged) {
27
-                dispatch(localRecordingEngaged());
27
+                const nowTime = new Date();
28
+
29
+                dispatch(localRecordingEngaged(nowTime));
28 30
             } else {
29 31
                 dispatch(localRecordingUnengaged());
30 32
             }

+ 2
- 2
react/features/local-recording/reducer.js Ver fichero

@@ -15,7 +15,7 @@ ReducerRegistry.register('features/local-recording', (state = {}, action) => {
15 15
         return {
16 16
             ...state,
17 17
             isEngaged: true,
18
-            recordingStartedAt: new Date(Date.now()),
18
+            recordingEngagedAt: action.recordingEngagedAt,
19 19
             encodingFormat: recordingController._format
20 20
         };
21 21
     }
@@ -23,7 +23,7 @@ ReducerRegistry.register('features/local-recording', (state = {}, action) => {
23 23
         return {
24 24
             ...state,
25 25
             isEngaged: false,
26
-            recordingStartedAt: null
26
+            recordingEngagedAt: null
27 27
         };
28 28
     case LOCAL_RECORDING_TOGGLE_DIALOG:
29 29
         return {

Loading…
Cancelar
Guardar