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

41 lines
898 B
JavaScript
Raw Normal View History

2017-04-28 17:14:44 +02:00
import { createSelector } from 'reselect'
import {
selectCurrentUri,
selectCurrentPage,
} from 'selectors/app'
export const _selectState = state => state.costInfo || {}
export const selectAllCostInfoByUri = createSelector(
_selectState,
(state) => state.byUri || {}
)
export const selectCurrentUriCostInfo = createSelector(
selectCurrentUri,
selectAllCostInfoByUri,
2017-05-12 19:14:06 +02:00
(uri, byUri) => byUri[uri]
2017-04-28 17:14:44 +02:00
)
export const selectFetchingCostInfo = createSelector(
_selectState,
(state) => state.fetching || {}
)
export const selectFetchingCurrentUriCostInfo = createSelector(
selectCurrentUri,
selectFetchingCostInfo,
(uri, byUri) => !!byUri[uri]
)
const selectCostInfoForUri = (state, props) => {
return selectAllCostInfoByUri(state)[props.uri]
}
export const makeSelectCostInfoForUri = () => {
return createSelector(
selectCostInfoForUri,
(costInfo) => costInfo
)
}