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

reducer.ts 1.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. import ReducerRegistry from '../base/redux/ReducerRegistry';
  2. import {
  3. PARTICIPANTS_PANE_CLOSE,
  4. PARTICIPANTS_PANE_OPEN,
  5. SET_VOLUME
  6. } from './actionTypes';
  7. import { REDUCER_KEY } from './constants';
  8. export interface IParticipantsPaneState {
  9. isOpen: boolean;
  10. participantsVolume: {
  11. [participantId: string]: number;
  12. };
  13. }
  14. const DEFAULT_STATE = {
  15. isOpen: false,
  16. participantsVolume: {}
  17. };
  18. /**
  19. * Listen for actions that mutate the participants pane state.
  20. */
  21. ReducerRegistry.register(
  22. REDUCER_KEY, (state: IParticipantsPaneState = DEFAULT_STATE, action) => {
  23. switch (action.type) {
  24. case PARTICIPANTS_PANE_CLOSE:
  25. return {
  26. ...state,
  27. isOpen: false
  28. };
  29. case PARTICIPANTS_PANE_OPEN:
  30. return {
  31. ...state,
  32. isOpen: true
  33. };
  34. case SET_VOLUME:
  35. return {
  36. ...state,
  37. participantsVolume: {
  38. ...state.participantsVolume,
  39. [action.participantId]: action.volume
  40. }
  41. };
  42. default:
  43. return state;
  44. }
  45. }
  46. );