Bettenbuk Zoltan ac63a0fa73 Calendar feature disabled state getter
This commit adds a state getter that considers checking the enabled/disabled state of the calendar feature, so then other features don’t have to do it manually.
2018-06-29 09:36:34 +01:00

19 lines
663 B
JavaScript

// @flow
import { toState } from '../base/redux';
import { CALENDAR_ENABLED, DEFAULT_STATE } from './constants';
/**
* Returns the calendar state, considering the enabled/disabled state of the
* feature. Since that is the normal Redux behaviour, this function will always
* return an object (the default state if the feature is disabled).
*
* @param {Object | Function} stateful - An object or a function that can be
* resolved to a Redux state by {@code toState}.
* @returns {Object}
*/
export function getCalendarState(stateful: Object | Function) {
return CALENDAR_ENABLED
? toState(stateful)['features/calendar-sync'] : DEFAULT_STATE;
}