jiti-meet/react/features/calendar-sync/reducer.js

43 lines
1.0 KiB
JavaScript
Raw Normal View History

2018-02-08 18:50:19 +00:00
// @flow
import { ReducerRegistry } from '../base/redux';
import {
2018-04-16 02:04:57 +00:00
SET_CALENDAR_AUTHORIZATION,
SET_CALENDAR_EVENTS
} from './actionTypes';
2018-04-16 16:39:26 +00:00
import { CALENDAR_ENABLED } from './constants';
2018-02-08 18:50:19 +00:00
const DEFAULT_STATE = {
/**
* Note: If features/calendar-sync ever gets persisted, do not persist the
2018-04-16 02:04:57 +00:00
* authorization value as it's needed to remain a runtime value to see if we
* need to re-request the calendar permission from the user.
*/
2018-04-16 02:04:57 +00:00
authorization: undefined,
events: []
2018-02-08 18:50:19 +00:00
};
2018-02-14 16:21:52 +00:00
2018-02-08 18:50:19 +00:00
const STORE_NAME = 'features/calendar-sync';
2018-04-16 16:39:26 +00:00
CALENDAR_ENABLED
&& ReducerRegistry.register(STORE_NAME, (state = DEFAULT_STATE, action) => {
switch (action.type) {
case SET_CALENDAR_AUTHORIZATION:
return {
...state,
authorization: action.status
};
case SET_CALENDAR_EVENTS:
return {
...state,
events: action.events
};
default:
return state;
}
});