| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 | // @flow
import { assign, ReducerRegistry, set } from '../base/redux';
import {
    MEDIA_PERMISSION_PROMPT_VISIBILITY_CHANGED,
    SET_FATAL_ERROR,
    SUSPEND_DETECTED
} from './actionTypes';
/**
 * Reduces the redux actions of the feature overlay.
 *
 * FIXME: these pieces of state should probably be in a different place.
 */
ReducerRegistry.register('features/overlay', (state = { }, action) => {
    switch (action.type) {
    case MEDIA_PERMISSION_PROMPT_VISIBILITY_CHANGED:
        return _mediaPermissionPromptVisibilityChanged(state, action);
    case SET_FATAL_ERROR:
        return _setFatalError(state, action);
    case SUSPEND_DETECTED:
        return _suspendDetected(state);
    }
    return state;
});
/**
 * Reduces a specific redux action MEDIA_PERMISSION_PROMPT_VISIBILITY_CHANGED of
 * the feature overlay.
 *
 * @param {Object} state - The redux state of the feature overlay.
 * @param {Action} action - The redux action to reduce.
 * @private
 * @returns {Object} The new state of the feature overlay after the reduction of
 * the specified action.
 */
function _mediaPermissionPromptVisibilityChanged(
        state,
        { browser, isVisible }) {
    return assign(state, {
        browser,
        isMediaPermissionPromptVisible: isVisible
    });
}
/**
 * Reduces a specific redux action SUSPEND_DETECTED of the feature overlay.
 *
 * @param {Object} state - The redux state of the feature overlay.
 * @private
 * @returns {Object} The new state of the feature overlay after the reduction of
 * the specified action.
 */
function _suspendDetected(state) {
    return set(state, 'suspendDetected', true);
}
/**
 * Reduces a specific redux action {@code SET_FATAL_ERROR} of the feature
 * overlay.
 *
 * @param {Object} state - The redux state of the feature overlay.
 * @param {Error} fatalError - If the value is set it indicates that a fatal
 * error has occurred and that the reload screen is to be displayed.
 * @returns {Object}
 * @private
 */
function _setFatalError(state, { fatalError }) {
    return set(state, 'fatalError', fatalError);
}
 |