Store claims by claim_id and fileinfo by sd_hash #192
3 changed files with 16 additions and 19 deletions
|
@ -10,23 +10,9 @@ export function doFetchCostInfoForUri(uri) {
|
|||
return function(dispatch, getState) {
|
||||
const state = getState(),
|
||||
claim = selectClaimsByUri(state)[uri],
|
||||
isResolving = selectResolvingUris(state).indexOf(uri) !== -1,
|
||||
isGenerous = selectSettingsIsGenerous(state);
|
||||
|
||||
if (claim === null) {
|
||||
//claim doesn't exist, nothing to fetch a cost for
|
||||
return;
|
||||
}
|
||||
|
||||
if (!claim) {
|
||||
setTimeout(() => {
|
||||
dispatch(doFetchCostInfoForUri(uri));
|
||||
}, 1000);
|
||||
if (!isResolving) {
|
||||
dispatch(doResolveUri(uri));
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (!claim) return null
|
||||
|
||||
function begin() {
|
||||
dispatch({
|
||||
|
|
|
@ -4,16 +4,21 @@ import { doFetchCostInfoForUri } from "actions/cost_info";
|
|||
import {
|
||||
makeSelectCostInfoForUri,
|
||||
makeSelectFetchingCostInfoForUri,
|
||||
} from "selectors/cost_info";
|
||||
import FilePrice from "./view";
|
||||
} from 'selectors/cost_info'
|
||||
import {
|
||||
makeSelectClaimForUri,
|
||||
} from 'selectors/claims'
|
||||
import FilePrice from './view'
|
||||
|
||||
const makeSelect = () => {
|
||||
const selectCostInfoForUri = makeSelectCostInfoForUri();
|
||||
const selectFetchingCostInfoForUri = makeSelectFetchingCostInfoForUri();
|
||||
const selectClaim = makeSelectClaimForUri();
|
||||
|
||||
const select = (state, props) => ({
|
||||
costInfo: selectCostInfoForUri(state, props),
|
||||
fetching: selectFetchingCostInfoForUri(state, props),
|
||||
claim: selectClaim(state, props),
|
||||
});
|
||||
|
||||
return select;
|
||||
|
|
|
@ -11,9 +11,15 @@ class FilePrice extends React.Component {
|
|||
}
|
||||
|
||||
fetchCost(props) {
|
||||
const { costInfo, fetchCostInfo, uri, fetching } = props;
|
||||
const {
|
||||
costInfo,
|
||||
fetchCostInfo,
|
||||
uri,
|
||||
fetching,
|
||||
claim,
|
||||
} = props;
|
||||
|
||||
if (costInfo === undefined && !fetching) {
|
||||
if (costInfo === undefined && !fetching && claim) {
|
||||
fetchCostInfo(uri);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue