2022-08-26 09:54:16 +00:00
|
|
|
import ReducerRegistry from '../base/redux/ReducerRegistry';
|
2023-02-14 09:50:46 +00:00
|
|
|
import { assign } from '../base/redux/functions';
|
|
|
|
|
|
|
|
import { MEDIA_PERMISSION_PROMPT_VISIBILITY_CHANGED } from './actionTypes';
|
2017-01-31 20:58:48 +00:00
|
|
|
|
|
|
|
|
2022-08-26 09:54:16 +00:00
|
|
|
export interface IOverlayState {
|
|
|
|
browser?: string;
|
|
|
|
fatalError?: Error;
|
|
|
|
isMediaPermissionPromptVisible?: boolean;
|
|
|
|
}
|
|
|
|
|
2017-01-31 20:58:48 +00:00
|
|
|
/**
|
2017-09-19 19:20:29 +00:00
|
|
|
* Reduces the redux actions of the feature overlay.
|
2017-11-09 13:34:42 +00:00
|
|
|
*
|
|
|
|
* FIXME: these pieces of state should probably be in a different place.
|
2017-01-31 20:58:48 +00:00
|
|
|
*/
|
2022-09-05 09:05:07 +00:00
|
|
|
ReducerRegistry.register<IOverlayState>('features/overlay', (state = {}, action): IOverlayState => {
|
2017-01-31 20:58:48 +00:00
|
|
|
switch (action.type) {
|
|
|
|
case MEDIA_PERMISSION_PROMPT_VISIBILITY_CHANGED:
|
|
|
|
return _mediaPermissionPromptVisibilityChanged(state, action);
|
|
|
|
}
|
|
|
|
|
|
|
|
return state;
|
|
|
|
});
|
|
|
|
|
2017-09-19 19:20:29 +00:00
|
|
|
/**
|
|
|
|
* Reduces a specific redux action MEDIA_PERMISSION_PROMPT_VISIBILITY_CHANGED of
|
2017-02-19 00:42:11 +00:00
|
|
|
* the feature overlay.
|
2017-01-31 20:58:48 +00:00
|
|
|
*
|
2017-09-19 19:20:29 +00:00
|
|
|
* @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-01-31 20:58:48 +00:00
|
|
|
*/
|
2017-10-04 22:36:09 +00:00
|
|
|
function _mediaPermissionPromptVisibilityChanged(
|
2022-08-26 09:54:16 +00:00
|
|
|
state: IOverlayState,
|
2022-09-08 09:52:36 +00:00
|
|
|
{ browser, isVisible }: { browser?: string; isVisible?: boolean; }) {
|
2017-04-22 22:57:08 +00:00
|
|
|
return assign(state, {
|
2017-10-04 22:36:09 +00:00
|
|
|
browser,
|
|
|
|
isMediaPermissionPromptVisible: isVisible
|
2017-01-31 20:58:48 +00:00
|
|
|
});
|
|
|
|
}
|