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 922B

123456789101112131415161718192021222324252627282930313233343536
  1. import {
  2. SET_CONFIG
  3. } from '../config';
  4. import { ReducerRegistry, set } from '../redux';
  5. import { SET_LAST_N } from './actionTypes';
  6. import { validateLastNLimits } from './functions';
  7. ReducerRegistry.register('features/base/lastn', (state = { }, action) => {
  8. switch (action.type) {
  9. case SET_CONFIG:
  10. return _setConfig(state, action);
  11. case SET_LAST_N: {
  12. const { lastN } = action;
  13. return {
  14. ...state,
  15. lastN
  16. };
  17. }
  18. }
  19. return state;
  20. });
  21. /**
  22. * Reduces a specific Redux action SET_CONFIG.
  23. *
  24. * @param {Object} state - The Redux state of feature base/lastn.
  25. * @param {Action} action - The Redux action SET_CONFIG to reduce.
  26. * @private
  27. * @returns {Object} The new state after the reduction of the specified action.
  28. */
  29. function _setConfig(state, { config }) {
  30. return set(state, 'lastNLimits', validateLastNLimits(config.lastNLimits));
  31. }