jiti-meet/react/features/external-api/middleware.js

46 lines
1.2 KiB
JavaScript
Raw Normal View History

// @flow
2019-06-08 17:35:11 +00:00
import { CONFERENCE_FAILED } from '../base/conference';
import { NOTIFY_CAMERA_ERROR, NOTIFY_MIC_ERROR } from '../base/devices';
2019-06-08 17:35:11 +00:00
import { JitsiConferenceErrors } from '../base/lib-jitsi-meet';
import { MiddlewareRegistry } from '../base/redux';
import { SUBMIT_FEEDBACK } from '../feedback';
declare var APP: Object;
/**
* The middleware of the feature {@code external-api}.
*
* @returns {Function}
*/
MiddlewareRegistry.register((/* store */) => next => action => {
switch (action.type) {
2019-06-08 17:35:11 +00:00
case CONFERENCE_FAILED: {
if (action.conference
&& action.error.name === JitsiConferenceErrors.PASSWORD_REQUIRED) {
APP.API.notifyOnPasswordRequired();
}
break;
}
case NOTIFY_CAMERA_ERROR:
if (action.error) {
APP.API.notifyOnCameraError(
action.error.name, action.error.message);
}
break;
case NOTIFY_MIC_ERROR:
if (action.error) {
APP.API.notifyOnMicError(action.error.name, action.error.message);
}
break;
case SUBMIT_FEEDBACK:
APP.API.notifyFeedbackSubmitted();
break;
}
return next(action);
});