Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

reducer.js 2.0KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. // @flow
  2. import { assign, ReducerRegistry, set } from '../base/redux';
  3. import {
  4. MEDIA_PERMISSION_PROMPT_VISIBILITY_CHANGED,
  5. SET_FATAL_ERROR,
  6. SUSPEND_DETECTED
  7. } from './actionTypes';
  8. /**
  9. * Reduces the redux actions of the feature overlay.
  10. *
  11. * FIXME: these pieces of state should probably be in a different place.
  12. */
  13. ReducerRegistry.register('features/overlay', (state = { }, action) => {
  14. switch (action.type) {
  15. case MEDIA_PERMISSION_PROMPT_VISIBILITY_CHANGED:
  16. return _mediaPermissionPromptVisibilityChanged(state, action);
  17. case SET_FATAL_ERROR:
  18. return _setFatalError(state, action);
  19. case SUSPEND_DETECTED:
  20. return _suspendDetected(state);
  21. }
  22. return state;
  23. });
  24. /**
  25. * Reduces a specific redux action MEDIA_PERMISSION_PROMPT_VISIBILITY_CHANGED of
  26. * the feature overlay.
  27. *
  28. * @param {Object} state - The redux state of the feature overlay.
  29. * @param {Action} action - The redux action to reduce.
  30. * @private
  31. * @returns {Object} The new state of the feature overlay after the reduction of
  32. * the specified action.
  33. */
  34. function _mediaPermissionPromptVisibilityChanged(
  35. state,
  36. { browser, isVisible }) {
  37. return assign(state, {
  38. browser,
  39. isMediaPermissionPromptVisible: isVisible
  40. });
  41. }
  42. /**
  43. * Reduces a specific redux action SUSPEND_DETECTED of the feature overlay.
  44. *
  45. * @param {Object} state - The redux state of the feature overlay.
  46. * @private
  47. * @returns {Object} The new state of the feature overlay after the reduction of
  48. * the specified action.
  49. */
  50. function _suspendDetected(state) {
  51. return set(state, 'suspendDetected', true);
  52. }
  53. /**
  54. * Reduces a specific redux action {@code SET_FATAL_ERROR} of the feature
  55. * overlay.
  56. *
  57. * @param {Object} state - The redux state of the feature overlay.
  58. * @param {Error} fatalError - If the value is set it indicates that a fatal
  59. * error has occurred and that the reload screen is to be displayed.
  60. * @returns {Object}
  61. * @private
  62. */
  63. function _setFatalError(state, { fatalError }) {
  64. return set(state, 'fatalError', fatalError);
  65. }