feat(recording): Move RECORDER_STATE_CHANGED handling to Redux

This commit is contained in:
Bettenbuk Zoltan
2018-05-30 12:13:32 +02:00
committed by Saúl Ibarra Corretgé
parent 5499599720
commit bced38cefc
3 changed files with 40 additions and 8 deletions
+1
View File
@@ -3,4 +3,5 @@ export * from './components';
export * from './constants';
export * from './functions';
import './middleware';
import './reducer';
+39
View File
@@ -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;
});