You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

reducer.ts 1.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. import ReducerRegistry from '../base/redux/ReducerRegistry';
  2. import { assign } from '../base/redux/functions';
  3. import { MEDIA_PERMISSION_PROMPT_VISIBILITY_CHANGED } from './actionTypes';
  4. export interface IOverlayState {
  5. browser?: string;
  6. fatalError?: Error;
  7. isMediaPermissionPromptVisible?: boolean;
  8. }
  9. /**
  10. * Reduces the redux actions of the feature overlay.
  11. *
  12. * FIXME: these pieces of state should probably be in a different place.
  13. */
  14. ReducerRegistry.register<IOverlayState>('features/overlay', (state = {}, action): IOverlayState => {
  15. switch (action.type) {
  16. case MEDIA_PERMISSION_PROMPT_VISIBILITY_CHANGED:
  17. return _mediaPermissionPromptVisibilityChanged(state, action);
  18. }
  19. return state;
  20. });
  21. /**
  22. * Reduces a specific redux action MEDIA_PERMISSION_PROMPT_VISIBILITY_CHANGED of
  23. * the feature overlay.
  24. *
  25. * @param {Object} state - The redux state of the feature overlay.
  26. * @param {Action} action - The redux action to reduce.
  27. * @private
  28. * @returns {Object} The new state of the feature overlay after the reduction of
  29. * the specified action.
  30. */
  31. function _mediaPermissionPromptVisibilityChanged(
  32. state: IOverlayState,
  33. { browser, isVisible }: { browser?: string; isVisible?: boolean; }) {
  34. return assign(state, {
  35. browser,
  36. isMediaPermissionPromptVisible: isVisible
  37. });
  38. }