2017-06-06 17:19:12 -04:00
|
|
|
import { createSelector } from "reselect";
|
2017-04-29 16:50:29 +07:00
|
|
|
|
2017-06-05 21:21:55 -07:00
|
|
|
const _selectState = state => state.availability;
|
2017-04-29 16:50:29 +07:00
|
|
|
|
|
|
|
export const selectAvailabilityByUri = createSelector(
|
|
|
|
_selectState,
|
2017-06-06 17:19:12 -04:00
|
|
|
state => state.byUri || {}
|
2017-06-05 21:21:55 -07:00
|
|
|
);
|
2017-04-29 16:50:29 +07:00
|
|
|
|
|
|
|
const selectAvailabilityForUri = (state, props) => {
|
2017-06-06 17:19:12 -04:00
|
|
|
return selectAvailabilityByUri(state)[props.uri];
|
2017-06-05 21:21:55 -07:00
|
|
|
};
|
2017-04-29 16:50:29 +07:00
|
|
|
|
2017-05-14 23:50:59 -04:00
|
|
|
export const makeSelectIsAvailableForUri = () => {
|
2017-04-29 16:50:29 +07:00
|
|
|
return createSelector(
|
|
|
|
selectAvailabilityForUri,
|
2017-06-06 17:19:12 -04:00
|
|
|
availability => (availability === undefined ? undefined : availability > 0)
|
|
|
|
);
|
2017-06-05 21:21:55 -07:00
|
|
|
};
|
2017-04-29 16:50:29 +07:00
|
|
|
|
2017-05-14 23:50:59 -04:00
|
|
|
export const selectFetchingAvailability = createSelector(
|
|
|
|
_selectState,
|
2017-06-06 17:19:12 -04:00
|
|
|
state => state.fetching || {}
|
2017-06-05 21:21:55 -07:00
|
|
|
);
|
2017-05-14 23:50:59 -04:00
|
|
|
|
2017-04-29 16:50:29 +07:00
|
|
|
const selectFetchingAvailabilityForUri = (state, props) => {
|
2017-06-06 17:19:12 -04:00
|
|
|
return selectFetchingAvailability(state)[props.uri];
|
2017-06-05 21:21:55 -07:00
|
|
|
};
|
2017-04-29 16:50:29 +07:00
|
|
|
|
|
|
|
export const makeSelectFetchingAvailabilityForUri = () => {
|
2017-06-06 17:19:12 -04:00
|
|
|
return createSelector(selectFetchingAvailabilityForUri, fetching => fetching);
|
2017-06-05 21:21:55 -07:00
|
|
|
};
|