jiti-meet/react/features/mobile/navigation/middleware.js

37 lines
1.1 KiB
JavaScript
Raw Normal View History

import { appNavigate } from '../../app/actions';
import { CONFERENCE_FAILED } from '../../base/conference/actionTypes';
import { JitsiConferenceErrors } from '../../base/lib-jitsi-meet';
2022-01-25 12:55:57 +00:00
import { MiddlewareRegistry } from '../../base/redux';
MiddlewareRegistry.register(store => next => action => {
switch (action.type) {
case CONFERENCE_FAILED:
return _conferenceFailed(store, next, action);
2022-01-25 12:55:57 +00:00
}
return next(action);
});
/**
* Function to handle the conference failed event and navigate the user to the lobby screen
* based on the failure reason.
*
* @param {Object} store - The Redux store.
* @param {Function} next - The Redux next function.
* @param {Object} action - The Redux action.
* @returns {Object}
*/
function _conferenceFailed({ dispatch }, next, action) {
const { error } = action;
// We need to cover the case where knocking participant
// is rejected from entering the conference
if (error.name === JitsiConferenceErrors.CONFERENCE_ACCESS_DENIED) {
dispatch(appNavigate(undefined));
}
return next(action);
}