Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

reducer.ts 1.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. import ReducerRegistry from '../base/redux/ReducerRegistry';
  2. import { RESET_WHITEBOARD, SETUP_WHITEBOARD } from './actionTypes';
  3. export interface IWhiteboardState {
  4. /**
  5. * The whiteboard collaboration details.
  6. */
  7. collabDetails?: { roomId: string; roomKey: string; };
  8. /**
  9. * The whiteboard collaboration url.
  10. */
  11. collabServerUrl?: string;
  12. /**
  13. * The indicator which determines whether the whiteboard is open.
  14. *
  15. * @type {boolean}
  16. */
  17. isOpen: boolean;
  18. }
  19. const DEFAULT_STATE: IWhiteboardState = {
  20. isOpen: false,
  21. collabDetails: undefined,
  22. collabServerUrl: undefined
  23. };
  24. export interface IWhiteboardAction extends Partial<IWhiteboardState> {
  25. /**
  26. * The whiteboard collaboration details.
  27. */
  28. collabDetails?: { roomId: string; roomKey: string; };
  29. /**
  30. * The whiteboard collaboration url.
  31. */
  32. collabServerUrl?: string;
  33. /**
  34. * The action type.
  35. */
  36. type: string;
  37. }
  38. ReducerRegistry.register(
  39. 'features/whiteboard',
  40. (state: IWhiteboardState = DEFAULT_STATE, action: IWhiteboardAction) => {
  41. switch (action.type) {
  42. case SETUP_WHITEBOARD: {
  43. return {
  44. ...state,
  45. isOpen: true,
  46. collabDetails: action.collabDetails,
  47. collabServerUrl: action.collabServerUrl
  48. };
  49. }
  50. case RESET_WHITEBOARD:
  51. return DEFAULT_STATE;
  52. }
  53. return state;
  54. });