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.js 1.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. // @flow
  2. import { ReducerRegistry } from '../base/redux';
  3. import {
  4. SET_CALENDAR_AUTHORIZATION,
  5. SET_CALENDAR_EVENTS
  6. } from './actionTypes';
  7. import { CALENDAR_ENABLED } from './constants';
  8. const DEFAULT_STATE = {
  9. /**
  10. * Note: If features/calendar-sync ever gets persisted, do not persist the
  11. * authorization value as it's needed to remain a runtime value to see if we
  12. * need to re-request the calendar permission from the user.
  13. */
  14. authorization: undefined,
  15. events: []
  16. };
  17. const STORE_NAME = 'features/calendar-sync';
  18. CALENDAR_ENABLED
  19. && ReducerRegistry.register(STORE_NAME, (state = DEFAULT_STATE, action) => {
  20. switch (action.type) {
  21. case SET_CALENDAR_AUTHORIZATION:
  22. return {
  23. ...state,
  24. authorization: action.status
  25. };
  26. case SET_CALENDAR_EVENTS:
  27. return {
  28. ...state,
  29. events: action.events
  30. };
  31. default:
  32. return state;
  33. }
  34. });