don't use params to switch actionType

This commit is contained in:
Radium Zheng 2018-07-10 04:09:14 +10:00
parent e125861b29
commit 337cea6488
2 changed files with 30 additions and 15 deletions

View File

@ -7,24 +7,35 @@ import {
LOCAL_RECORDING_STATS_UPDATE
} from './actionTypes';
// The following two actions signal state changes in local recording engagement.
// In other words, the events of the local WebWorker / MediaRecorder starting to
// record and finishing recording.
// Note that this is not the event fired when the users tries to start the
// recording in the UI.
/**
* Signals state change in local recording engagement.
* In other words, the events of the local WebWorker / MediaRecorder
* starting to record and finishing recording.
* Signals that local recording has started.
*
* Note that this is not the event fired when the users tries to start
* the recording in the UI.
*
* @param {bool} isEngaged - Whether local recording is engaged or not.
* @returns {{
* type: LOCAL_RECORDING_ENGAGED
* }|{
* }}
*/
export function localRecordingEngaged() {
return {
type: LOCAL_RECORDING_ENGAGED
};
}
/**
* Signals that local recording has finished.
*
* @returns {{
* type: LOCAL_RECORDING_UNENGAGED
* }}
*/
export function signalLocalRecordingEngagement(isEngaged: boolean) {
export function localRecordingUnengaged() {
return {
type: isEngaged ? LOCAL_RECORDING_ENGAGED : LOCAL_RECORDING_UNENGAGED
type: LOCAL_RECORDING_UNENGAGED
};
}

View File

@ -6,8 +6,8 @@ import { i18next } from '../base/i18n';
import { MiddlewareRegistry } from '../base/redux';
import { showNotification } from '../notifications';
import { localRecordingEngaged, localRecordingUnengaged } from './actions';
import { recordingController } from './controller';
import { signalLocalRecordingEngagement } from './actions';
MiddlewareRegistry.register(({ getState, dispatch }) => next => action => {
const result = next(action);
@ -20,10 +20,14 @@ MiddlewareRegistry.register(({ getState, dispatch }) => next => action => {
break;
}
case APP_WILL_MOUNT:
// realize the delegates on recordingController,
// providing UI reactions.
recordingController.onStateChanged = function(state) {
dispatch(signalLocalRecordingEngagement(state));
// realize the delegates on recordingController, allowing the UI to
// react to state changes in recordingController.
recordingController.onStateChanged = function(isEngaged) {
if (isEngaged) {
dispatch(localRecordingEngaged());
} else {
dispatch(localRecordingUnengaged());
}
};
recordingController.onWarning = function(message) {