jiti-meet/react/features/overlay/reducer.js

57 lines
1.5 KiB
JavaScript
Raw Normal View History

2017-10-04 22:36:09 +00:00
// @flow
import { assign, ReducerRegistry, set } from '../base/redux';
import {
MEDIA_PERMISSION_PROMPT_VISIBILITY_CHANGED,
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 SUSPEND_DETECTED:
return _suspendDetected(state);
}
return state;
});
/**
* Reduces a specific redux action MEDIA_PERMISSION_PROMPT_VISIBILITY_CHANGED of
2017-02-19 00:42:11 +00:00
* the feature overlay.
*
* @param {Object} state - The redux state of the feature overlay.
* @param {Action} action - The redux action to reduce.
* @private
2017-02-19 00:42:11 +00:00
* @returns {Object} The new state of the feature overlay after the reduction of
* the specified action.
*/
2017-10-04 22:36:09 +00:00
function _mediaPermissionPromptVisibilityChanged(
state,
{ browser, isVisible }) {
return assign(state, {
2017-10-04 22:36:09 +00:00
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
2017-02-19 00:42:11 +00:00
* @returns {Object} The new state of the feature overlay after the reduction of
* the specified action.
*/
function _suspendDetected(state) {
return set(state, 'suspendDetected', true);
}