Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

reducer.js 1.5KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. import { equals, ReducerRegistry } from '../redux';
  2. import { SET_LOGGING_CONFIG } from './actionTypes';
  3. /**
  4. * The initial state of the feature base/logging.
  5. *
  6. * @type {{
  7. * config: Object
  8. * }}
  9. */
  10. const INITIAL_STATE = {
  11. config: {
  12. defaultLogLevel: 'trace',
  13. // The following are too verbose in their logging with the
  14. // {@link #defaultLogLevel}:
  15. 'modules/statistics/CallStats.js': 'info',
  16. 'modules/xmpp/strophe.util.js': 'log'
  17. }
  18. };
  19. ReducerRegistry.register(
  20. 'features/base/logging',
  21. (state = INITIAL_STATE, action) => {
  22. switch (action.type) {
  23. case SET_LOGGING_CONFIG:
  24. return _setLoggingConfig(state, action);
  25. default:
  26. return state;
  27. }
  28. });
  29. /**
  30. * Reduces a specific Redux action SET_LOGGING_CONFIG of the feature
  31. * base/logging.
  32. *
  33. * @param {Object} state - The Redux state of the feature base/logging.
  34. * @param {Action} action - The Redux action SET_LOGGING_CONFIG to reduce.
  35. * @private
  36. * @returns {Object} The new state of the feature base/logging after the
  37. * reduction of the specified action.
  38. */
  39. function _setLoggingConfig(state, action) {
  40. const config = {
  41. // The config of INITIAL_STATE is the default configuration of the
  42. // feature base/logging.
  43. ...INITIAL_STATE.config,
  44. ...action.config
  45. };
  46. if (equals(state.config, config)) {
  47. return state;
  48. }
  49. return {
  50. ...state,
  51. config
  52. };
  53. }