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

30 lines
795 B
JavaScript
Raw Normal View History

2017-06-06 23:19:12 +02:00
import { createSelector } from "reselect";
2017-04-28 17:14:44 +02:00
2017-06-06 06:21:55 +02:00
export const _selectState = state => state.costInfo || {};
2017-04-28 17:14:44 +02:00
export const selectAllCostInfoByUri = createSelector(
_selectState,
2017-06-06 23:19:12 +02:00
state => state.byUri || {}
2017-06-06 06:21:55 +02:00
);
2017-04-28 17:14:44 +02:00
2017-05-15 05:50:59 +02:00
export const selectCostInfoForUri = (state, props) => {
2017-06-06 23:19:12 +02:00
return selectAllCostInfoByUri(state)[props.uri];
2017-06-06 06:21:55 +02:00
};
export const makeSelectCostInfoForUri = () => {
2017-06-06 23:19:12 +02:00
return createSelector(selectCostInfoForUri, costInfo => costInfo);
2017-06-06 06:21:55 +02:00
};
export const selectFetchingCostInfo = createSelector(
_selectState,
2017-06-06 23:19:12 +02:00
state => state.fetching || {}
2017-06-06 06:21:55 +02:00
);
const selectFetchingCostInfoForUri = (state, props) => {
2017-06-06 23:19:12 +02:00
return selectFetchingCostInfo(state)[props.uri];
2017-06-06 06:21:55 +02:00
};
export const makeSelectFetchingCostInfoForUri = () => {
2017-06-06 23:19:12 +02:00
return createSelector(selectFetchingCostInfoForUri, fetching => !!fetching);
2017-06-06 06:21:55 +02:00
};