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

36 lines
925 B
JavaScript
Raw Normal View History

2017-06-06 23:19:12 +02:00
import { createSelector } from "reselect";
2017-11-13 22:02:23 +01:00
import { selectCurrentParams } from "redux/selectors/navigation";
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-09-08 05:15:05 +02:00
export const makeSelectCostInfoForUri = uri => {
return createSelector(
selectAllCostInfoByUri,
costInfos => costInfos && costInfos[uri]
);
2017-06-06 06:21:55 +02:00
};
2017-08-22 23:19:33 +02:00
export const selectCostForCurrentPageUri = createSelector(
selectAllCostInfoByUri,
selectCurrentParams,
(costInfo, params) =>
params.uri && costInfo[params.uri] ? costInfo[params.uri].cost : undefined
);
export const selectFetchingCostInfo = createSelector(
_selectState,
2017-06-06 23:19:12 +02:00
state => state.fetching || {}
2017-06-06 06:21:55 +02:00
);
2017-09-08 05:15:05 +02:00
export const makeSelectFetchingCostInfoForUri = uri => {
return createSelector(
selectFetchingCostInfo,
fetchingByUri => fetchingByUri && fetchingByUri[uri]
);
2017-06-06 06:21:55 +02:00
};