lbry-desktop/ui/js/selectors/availability.js

41 lines
959 B
JavaScript
Raw Normal View History

import {
createSelector,
} from 'reselect'
import {
selectDaemonReady,
selectCurrentPage,
} from 'selectors/app'
const _selectState = state => state.availability
export const selectAvailabilityByUri = createSelector(
_selectState,
(state) => state.byUri || {}
)
const selectAvailabilityForUri = (state, props) => {
return selectAvailabilityByUri(state)[props.uri]
}
2017-05-15 05:50:59 +02:00
export const makeSelectIsAvailableForUri = () => {
return createSelector(
selectAvailabilityForUri,
2017-05-15 05:50:59 +02:00
(availability) => availability === undefined ? undefined : availability > 0
)
}
2017-05-15 05:50:59 +02:00
export const selectFetchingAvailability = createSelector(
_selectState,
(state) => state.fetching || {}
)
const selectFetchingAvailabilityForUri = (state, props) => {
2017-05-15 05:50:59 +02:00
return selectFetchingAvailability(state)[props.uri]
}
export const makeSelectFetchingAvailabilityForUri = () => {
return createSelector(
selectFetchingAvailabilityForUri,
(fetching) => fetching
)
2017-05-15 05:50:59 +02:00
}