lbry-desktop/src/renderer/redux/selectors/availability.js

28 lines
662 B
JavaScript
Raw Normal View History

2017-06-06 23:19:12 +02:00
import { createSelector } from "reselect";
2017-06-06 06:21:55 +02:00
const _selectState = state => state.availability;
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-09-08 05:15:05 +02:00
export const makeSelectIsAvailableForUri = uri => {
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-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
};