feat(recording): Move RECORDER_STATE_CHANGED handling to Redux

This commit is contained in:
Bettenbuk Zoltan 2018-05-23 16:20:10 +02:00 committed by Saúl Ibarra Corretgé
parent 5499599720
commit bced38cefc
3 changed files with 40 additions and 8 deletions

View File

@ -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.

View File

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

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