Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. // @flow
  2. import { assign, ReducerRegistry, set } from '../base/redux';
  3. import {
  4. MEDIA_PERMISSION_PROMPT_VISIBILITY_CHANGED,
  5. SUSPEND_DETECTED
  6. } from './actionTypes';
  7. /**
  8. * Reduces the redux actions of the feature overlay.
  9. *
  10. * FIXME: these pieces of state should probably be in a different place.
  11. */
  12. ReducerRegistry.register('features/overlay', (state = {}, action) => {
  13. switch (action.type) {
  14. case MEDIA_PERMISSION_PROMPT_VISIBILITY_CHANGED:
  15. return _mediaPermissionPromptVisibilityChanged(state, action);
  16. case SUSPEND_DETECTED:
  17. return _suspendDetected(state);
  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,
  33. { browser, isVisible }) {
  34. return assign(state, {
  35. browser,
  36. isMediaPermissionPromptVisible: isVisible
  37. });
  38. }
  39. /**
  40. * Reduces a specific redux action SUSPEND_DETECTED of the feature overlay.
  41. *
  42. * @param {Object} state - The redux state of the feature overlay.
  43. * @private
  44. * @returns {Object} The new state of the feature overlay after the reduction of
  45. * the specified action.
  46. */
  47. function _suspendDetected(state) {
  48. return set(state, 'suspendDetected', true);
  49. }