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