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
|
|
|
|
2017-09-08 05:15:05 +02:00
|
|
|
export const makeSelectIsAvailableForUri = uri => {
|
2017-04-29 11:50:29 +02:00
|
|
|
return createSelector(
|
2017-09-08 05:15:05 +02:00
|
|
|
selectAvailabilityByUri,
|
|
|
|
byUri => (!byUri || byUri[uri] === undefined ? undefined : byUri[uri] > 0)
|
2017-06-06 23:19:12 +02:00
|
|
|
);
|
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-09-08 05:15:05 +02:00
|
|
|
export const makeSelectFetchingAvailabilityForUri = uri => {
|
|
|
|
return createSelector(
|
|
|
|
selectFetchingAvailability,
|
|
|
|
byUri => byUri && byUri[uri]
|
|
|
|
);
|
2017-06-06 06:21:55 +02:00
|
|
|
};
|