Procházet zdrojové kódy

feat(recording): Move RECORDER_STATE_CHANGED handling to Redux

j8
Bettenbuk Zoltan před 7 roky
rodič
revize
bced38cefc

+ 0
- 8
conference.js Zobrazit soubor

@@ -27,7 +27,6 @@ import {
27 27
     redirectWithStoredParams,
28 28
     reloadWithStoredParams
29 29
 } from './react/features/app';
30
-import { updateRecordingSessionData } from './react/features/recording';
31 30
 
32 31
 import EventEmitter from 'events';
33 32
 
@@ -1946,13 +1945,6 @@ export default {
1946 1945
                     return;
1947 1946
                 }
1948 1947
 
1949
-                if (recorderSession.getID()) {
1950
-                    APP.store.dispatch(
1951
-                        updateRecordingSessionData(recorderSession));
1952
-
1953
-                    return;
1954
-                }
1955
-
1956 1948
                 // These errors fire when the local participant has requested a
1957 1949
                 // recording but the request itself failed, hence the missing
1958 1950
                 // session ID because the recorder never started.

+ 1
- 0
react/features/recording/index.js Zobrazit soubor

@@ -3,4 +3,5 @@ export * from './components';
3 3
 export * from './constants';
4 4
 export * from './functions';
5 5
 
6
+import './middleware';
6 7
 import './reducer';

+ 39
- 0
react/features/recording/middleware.js Zobrazit soubor

@@ -0,0 +1,39 @@
1
+/* @flow */
2
+
3
+import { CONFERENCE_WILL_JOIN } from '../base/conference';
4
+import { JitsiConferenceEvents } from '../base/lib-jitsi-meet';
5
+import { MiddlewareRegistry } from '../base/redux';
6
+
7
+import { updateRecordingSessionData } from './actions';
8
+
9
+/**
10
+ * The redux middleware to handle the recorder updates in a React way.
11
+ *
12
+ * @param {Store} store - The redux store.
13
+ * @returns {Function}
14
+ */
15
+MiddlewareRegistry.register(({ dispatch }) => next => action => {
16
+    const result = next(action);
17
+
18
+    switch (action.type) {
19
+    case CONFERENCE_WILL_JOIN: {
20
+        const { conference } = action;
21
+
22
+        conference.on(
23
+            JitsiConferenceEvents.RECORDER_STATE_CHANGED,
24
+            recorderSession => {
25
+
26
+                if (recorderSession && recorderSession.getID()) {
27
+                    dispatch(
28
+                        updateRecordingSessionData(recorderSession));
29
+
30
+                    return;
31
+                }
32
+            });
33
+
34
+        break;
35
+    }
36
+    }
37
+
38
+    return result;
39
+});

Načítá se…
Zrušit
Uložit