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.js 1.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. // @flow
  2. import { ReducerRegistry } from '../base/redux';
  3. import {
  4. ETHERPAD_INITIALIZED,
  5. SET_DOCUMENT_EDITING_STATUS,
  6. SET_DOCUMENT_URL
  7. } from './actionTypes';
  8. const DEFAULT_STATE = {
  9. /**
  10. * URL for the shared document.
  11. */
  12. documentUrl: undefined,
  13. /**
  14. * Whether or not Etherpad is currently open.
  15. *
  16. * @public
  17. * @type {boolean}
  18. */
  19. editing: false,
  20. /**
  21. * Whether or not Etherpad is ready to use.
  22. *
  23. * @public
  24. * @type {boolean}
  25. */
  26. initialized: false
  27. };
  28. /**
  29. * Reduces the Redux actions of the feature features/etherpad.
  30. */
  31. ReducerRegistry.register(
  32. 'features/etherpad',
  33. (state = DEFAULT_STATE, action) => {
  34. switch (action.type) {
  35. case ETHERPAD_INITIALIZED:
  36. return {
  37. ...state,
  38. initialized: true
  39. };
  40. case SET_DOCUMENT_EDITING_STATUS:
  41. return {
  42. ...state,
  43. editing: action.editing
  44. };
  45. case SET_DOCUMENT_URL:
  46. return {
  47. ...state,
  48. documentUrl: action.documentUrl
  49. };
  50. default:
  51. return state;
  52. }
  53. });