You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

reducer.ts 1.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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 indicator which determines whether the whiteboard is open.
  10. *
  11. * @type {boolean}
  12. */
  13. isOpen: boolean;
  14. }
  15. const DEFAULT_STATE: IWhiteboardState = {
  16. isOpen: false,
  17. collabDetails: undefined
  18. };
  19. export interface IWhiteboardAction extends Partial<IWhiteboardState> {
  20. /**
  21. * The whiteboard collaboration details.
  22. */
  23. collabDetails?: { roomId: string; roomKey: string; };
  24. /**
  25. * The action type.
  26. */
  27. type: string;
  28. }
  29. ReducerRegistry.register(
  30. 'features/whiteboard',
  31. (state: IWhiteboardState = DEFAULT_STATE, action: IWhiteboardAction) => {
  32. switch (action.type) {
  33. case SETUP_WHITEBOARD: {
  34. return {
  35. ...state,
  36. isOpen: true,
  37. collabDetails: action.collabDetails
  38. };
  39. }
  40. case RESET_WHITEBOARD:
  41. return DEFAULT_STATE;
  42. }
  43. return state;
  44. });