2022-08-26 12:54:16 +03:00
|
|
|
import ReducerRegistry from '../base/redux/ReducerRegistry';
|
2023-02-14 11:50:46 +02:00
|
|
|
import { assign } from '../base/redux/functions';
|
|
|
|
|
|
|
|
|
|
import { MEDIA_PERMISSION_PROMPT_VISIBILITY_CHANGED } from './actionTypes';
|
2017-01-31 14:58:48 -06:00
|
|
|
|
|
|
|
|
|
2022-08-26 12:54:16 +03:00
|
|
|
export interface IOverlayState {
|
|
|
|
|
browser?: string;
|
2023-03-29 10:04:23 +03:00
|
|
|
fatalError?: {
|
|
|
|
|
details: Object;
|
|
|
|
|
message?: string;
|
|
|
|
|
name?: string;
|
|
|
|
|
};
|
2022-08-26 12:54:16 +03:00
|
|
|
isMediaPermissionPromptVisible?: boolean;
|
|
|
|
|
}
|
|
|
|
|
|
2017-01-31 14:58:48 -06:00
|
|
|
/**
|
2017-09-19 14:20:29 -05:00
|
|
|
* Reduces the redux actions of the feature overlay.
|
2017-11-09 14:34:42 +01:00
|
|
|
*
|
|
|
|
|
* FIXME: these pieces of state should probably be in a different place.
|
2017-01-31 14:58:48 -06:00
|
|
|
*/
|
2022-09-05 12:05:07 +03:00
|
|
|
ReducerRegistry.register<IOverlayState>('features/overlay', (state = {}, action): IOverlayState => {
|
2017-01-31 14:58:48 -06:00
|
|
|
switch (action.type) {
|
|
|
|
|
case MEDIA_PERMISSION_PROMPT_VISIBILITY_CHANGED:
|
|
|
|
|
return _mediaPermissionPromptVisibilityChanged(state, action);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return state;
|
|
|
|
|
});
|
|
|
|
|
|
2017-09-19 14:20:29 -05:00
|
|
|
/**
|
|
|
|
|
* Reduces a specific redux action MEDIA_PERMISSION_PROMPT_VISIBILITY_CHANGED of
|
2017-02-18 18:42:11 -06:00
|
|
|
* the feature overlay.
|
2017-01-31 14:58:48 -06:00
|
|
|
*
|
2017-09-19 14:20:29 -05:00
|
|
|
* @param {Object} state - The redux state of the feature overlay.
|
|
|
|
|
* @param {Action} action - The redux action to reduce.
|
|
|
|
|
* @private
|
2017-02-18 18:42:11 -06:00
|
|
|
* @returns {Object} The new state of the feature overlay after the reduction of
|
|
|
|
|
* the specified action.
|
2017-01-31 14:58:48 -06:00
|
|
|
*/
|
2017-10-04 17:36:09 -05:00
|
|
|
function _mediaPermissionPromptVisibilityChanged(
|
2022-08-26 12:54:16 +03:00
|
|
|
state: IOverlayState,
|
2022-09-08 12:52:36 +03:00
|
|
|
{ browser, isVisible }: { browser?: string; isVisible?: boolean; }) {
|
2017-04-22 17:57:08 -05:00
|
|
|
return assign(state, {
|
2017-10-04 17:36:09 -05:00
|
|
|
browser,
|
|
|
|
|
isMediaPermissionPromptVisible: isVisible
|
2017-01-31 14:58:48 -06:00
|
|
|
});
|
|
|
|
|
}
|