您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

reducer.js 933B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. import {
  2. ReducerRegistry
  3. } from '../base/redux';
  4. import {
  5. CANCEL_FEEDBACK,
  6. SUBMIT_FEEDBACK
  7. } from './actionTypes';
  8. const DEFAULT_STATE = {
  9. message: '',
  10. // The sentinel value -1 is used to denote no rating has been set and to
  11. // preserve pre-redux behavior.
  12. score: -1,
  13. submitted: false
  14. };
  15. /**
  16. * Reduces the Redux actions of the feature features/feedback.
  17. */
  18. ReducerRegistry.register(
  19. 'features/feedback',
  20. (state = DEFAULT_STATE, action) => {
  21. switch (action.type) {
  22. case CANCEL_FEEDBACK: {
  23. return {
  24. ...state,
  25. message: action.message,
  26. score: action.score
  27. };
  28. }
  29. case SUBMIT_FEEDBACK: {
  30. return {
  31. ...state,
  32. message: '',
  33. score: -1,
  34. submitted: true
  35. };
  36. }
  37. }
  38. return state;
  39. });