lbry-desktop/ui/js/selectors/cost_info.js
2017-06-06 17:19:12 -04:00

29 lines
795 B
JavaScript

import { createSelector } from "reselect";
export const _selectState = state => state.costInfo || {};
export const selectAllCostInfoByUri = createSelector(
_selectState,
state => state.byUri || {}
);
export const selectCostInfoForUri = (state, props) => {
return selectAllCostInfoByUri(state)[props.uri];
};
export const makeSelectCostInfoForUri = () => {
return createSelector(selectCostInfoForUri, costInfo => costInfo);
};
export const selectFetchingCostInfo = createSelector(
_selectState,
state => state.fetching || {}
);
const selectFetchingCostInfoForUri = (state, props) => {
return selectFetchingCostInfo(state)[props.uri];
};
export const makeSelectFetchingCostInfoForUri = () => {
return createSelector(selectFetchingCostInfoForUri, fetching => !!fetching);
};