diff --git a/conference.js b/conference.js index a96043789..7b7f308ce 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 755b50deb..c95362f28 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 000000000..407735ee3 --- /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; +});