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

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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. };
  18. export interface IWhiteboardAction extends Partial<IWhiteboardState> {
  19. /**
  20. * The whiteboard collaboration details.
  21. */
  22. collabDetails?: { roomId: string; roomKey: string; };
  23. /**
  24. * The action type.
  25. */
  26. type: string;
  27. }
  28. ReducerRegistry.register(
  29. 'features/whiteboard',
  30. (state: IWhiteboardState = DEFAULT_STATE, action: IWhiteboardAction) => {
  31. switch (action.type) {
  32. case SETUP_WHITEBOARD: {
  33. return {
  34. ...state,
  35. isOpen: true,
  36. collabDetails: action.collabDetails
  37. };
  38. }
  39. case RESET_WHITEBOARD:
  40. return DEFAULT_STATE;
  41. }
  42. return state;
  43. });