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

reducer.ts 1002B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. import { CONFERENCE_WILL_LEAVE } from '../base/conference/actionTypes';
  2. import ReducerRegistry from '../base/redux/ReducerRegistry';
  3. import { I_AM_VISITOR_MODE, UPDATE_VISITORS_COUNT } from './actionTypes';
  4. const DEFAULT_STATE = {
  5. count: -1,
  6. iAmVisitor: false,
  7. showNotification: false
  8. };
  9. export interface IVisitorsState {
  10. count?: number;
  11. iAmVisitor: boolean;
  12. }
  13. ReducerRegistry.register<IVisitorsState>('features/visitors', (state = DEFAULT_STATE, action): IVisitorsState => {
  14. switch (action.type) {
  15. case CONFERENCE_WILL_LEAVE: {
  16. return {
  17. ...state,
  18. ...DEFAULT_STATE
  19. };
  20. }
  21. case UPDATE_VISITORS_COUNT: {
  22. if (state.count === action.count) {
  23. return state;
  24. }
  25. return {
  26. ...state,
  27. count: action.count
  28. };
  29. }
  30. case I_AM_VISITOR_MODE: {
  31. return {
  32. ...state,
  33. iAmVisitor: action.enabled
  34. };
  35. }
  36. }
  37. return state;
  38. });