Skip to content

Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.

feat(recording): Move RECORDER_STATE_CHANGED handling to Redux

Bettenbuk Zoltanbced38cefcb5
diff --git a/conference.js b/conference.js
index a960437892..7b7f308cec 100644
--- a/conference.js
+++ b/conference.js
@@ -27,7 +27,6 @@ import {
redirectWithStoredParams,
reloadWithStoredParams
} from './react/features/app';
-import { updateRecordingSessionData } from './react/features/recording';
import EventEmitter from 'events';
@@ -1946,13 +1945,6 @@ export default {
return;
}
- if (recorderSession.getID()) {
- APP.store.dispatch(
- updateRecordingSessionData(recorderSession));
-
- return;
- }
-
// These errors fire when the local participant has requested a
// recording but the request itself failed, hence the missing
// session ID because the recorder never started.
diff --git a/react/features/recording/index.js b/react/features/recording/index.js
index 755b50deb9..c95362f28f 100644
--- a/react/features/recording/index.js
+++ b/react/features/recording/index.js
@@ -3,4 +3,5 @@ export * from './components';
export * from './constants';
export * from './functions';
+import './middleware';
import './reducer';
diff --git a/react/features/recording/middleware.js b/react/features/recording/middleware.js
new file mode 100644
index 0000000000..407735ee36
--- /dev/null
+++ b/react/features/recording/middleware.js
@@ -0,0 +1,39 @@
+/* @flow */
+
+import { CONFERENCE_WILL_JOIN } from '../base/conference';
+import { JitsiConferenceEvents } from '../base/lib-jitsi-meet';
+import { MiddlewareRegistry } from '../base/redux';
+
+import { updateRecordingSessionData } from './actions';
+
+/**
+ * The redux middleware to handle the recorder updates in a React way.
+ *
+ * @param {Store} store - The redux store.
+ * @returns {Function}
+ */
+MiddlewareRegistry.register(({ dispatch }) => next => action => {
+ const result = next(action);
+
+ switch (action.type) {
+ case CONFERENCE_WILL_JOIN: {
+ const { conference } = action;
+
+ conference.on(
+ JitsiConferenceEvents.RECORDER_STATE_CHANGED,
+ recorderSession => {
+
+ if (recorderSession && recorderSession.getID()) {
+ dispatch(
+ updateRecordingSessionData(recorderSession));
+
+ return;
+ }
+ });
+
+ break;
+ }
+ }
+
+ return result;
+});