Browse Source

feat(recording): Move RECORDER_STATE_CHANGED handling to Redux

j8
Bettenbuk Zoltan 7 years ago
parent
commit
bced38cefc
3 changed files with 40 additions and 8 deletions
  1. 0
    8
      conference.js
  2. 1
    0
      react/features/recording/index.js
  3. 39
    0
      react/features/recording/middleware.js

+ 0
- 8
conference.js View File

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

+ 1
- 0
react/features/recording/index.js View File

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

+ 39
- 0
react/features/recording/middleware.js View File

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
+});

Loading…
Cancel
Save