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

reducer should be a pure function

master
Radium Zheng 7 роки тому
джерело
коміт
0f3b67e53e

+ 6
- 4
react/features/local-recording/actionTypes.js Переглянути файл

3
  * (as in: {@code RecordingAdapter} is actively collecting audio data).
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
 export const LOCAL_RECORDING_ENGAGED = Symbol('LOCAL_RECORDING_ENGAGED');
10
 export const LOCAL_RECORDING_ENGAGED = Symbol('LOCAL_RECORDING_ENGAGED');
29
     = Symbol('LOCAL_RECORDING_TOGGLE_DIALOG');
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
 export const LOCAL_RECORDING_STATS_UPDATE
41
 export const LOCAL_RECORDING_STATS_UPDATE

+ 7
- 4
react/features/local-recording/actions.js Переглянути файл

14
 // recording in the UI.
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
  * @returns {{
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
     return {
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 Переглянути файл

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

+ 3
- 1
react/features/local-recording/middleware.js Переглянути файл

24
         // react to state changes in recordingController.
24
         // react to state changes in recordingController.
25
         recordingController.onStateChanged = function(isEngaged) {
25
         recordingController.onStateChanged = function(isEngaged) {
26
             if (isEngaged) {
26
             if (isEngaged) {
27
-                dispatch(localRecordingEngaged());
27
+                const nowTime = new Date();
28
+
29
+                dispatch(localRecordingEngaged(nowTime));
28
             } else {
30
             } else {
29
                 dispatch(localRecordingUnengaged());
31
                 dispatch(localRecordingUnengaged());
30
             }
32
             }

+ 2
- 2
react/features/local-recording/reducer.js Переглянути файл

15
         return {
15
         return {
16
             ...state,
16
             ...state,
17
             isEngaged: true,
17
             isEngaged: true,
18
-            recordingStartedAt: new Date(Date.now()),
18
+            recordingEngagedAt: action.recordingEngagedAt,
19
             encodingFormat: recordingController._format
19
             encodingFormat: recordingController._format
20
         };
20
         };
21
     }
21
     }
23
         return {
23
         return {
24
             ...state,
24
             ...state,
25
             isEngaged: false,
25
             isEngaged: false,
26
-            recordingStartedAt: null
26
+            recordingEngagedAt: null
27
         };
27
         };
28
     case LOCAL_RECORDING_TOGGLE_DIALOG:
28
     case LOCAL_RECORDING_TOGGLE_DIALOG:
29
         return {
29
         return {

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