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.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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?: {
  7. details: Object;
  8. message?: string;
  9. name?: string;
  10. };
  11. isMediaPermissionPromptVisible?: boolean;
  12. }
  13. /**
  14. * Reduces the redux actions of the feature overlay.
  15. *
  16. * FIXME: these pieces of state should probably be in a different place.
  17. */
  18. ReducerRegistry.register<IOverlayState>('features/overlay', (state = {}, action): IOverlayState => {
  19. switch (action.type) {
  20. case MEDIA_PERMISSION_PROMPT_VISIBILITY_CHANGED:
  21. return _mediaPermissionPromptVisibilityChanged(state, action);
  22. }
  23. return state;
  24. });
  25. /**
  26. * Reduces a specific redux action MEDIA_PERMISSION_PROMPT_VISIBILITY_CHANGED of
  27. * the feature overlay.
  28. *
  29. * @param {Object} state - The redux state of the feature overlay.
  30. * @param {Action} action - The redux action to reduce.
  31. * @private
  32. * @returns {Object} The new state of the feature overlay after the reduction of
  33. * the specified action.
  34. */
  35. function _mediaPermissionPromptVisibilityChanged(
  36. state: IOverlayState,
  37. { browser, isVisible }: { browser?: string; isVisible?: boolean; }) {
  38. return assign(state, {
  39. browser,
  40. isMediaPermissionPromptVisible: isVisible
  41. });
  42. }