Stop cost info getting into an infinite loop
This commit is contained in:
parent
f97ec7b390
commit
c023a41a28
3 changed files with 16 additions and 19 deletions
|
@ -10,23 +10,9 @@ export function doFetchCostInfoForUri(uri) {
|
||||||
return function(dispatch, getState) {
|
return function(dispatch, getState) {
|
||||||
const state = getState(),
|
const state = getState(),
|
||||||
claim = selectClaimsByUri(state)[uri],
|
claim = selectClaimsByUri(state)[uri],
|
||||||
isResolving = selectResolvingUris(state).indexOf(uri) !== -1,
|
|
||||||
isGenerous = selectSettingsIsGenerous(state);
|
isGenerous = selectSettingsIsGenerous(state);
|
||||||
|
|
||||||
if (claim === null) {
|
if (!claim) return 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;
|
|
||||||
}
|
|
||||||
|
|
||||||
function begin() {
|
function begin() {
|
||||||
dispatch({
|
dispatch({
|
||||||
|
|
|
@ -4,16 +4,21 @@ import { doFetchCostInfoForUri } from "actions/cost_info";
|
||||||
import {
|
import {
|
||||||
makeSelectCostInfoForUri,
|
makeSelectCostInfoForUri,
|
||||||
makeSelectFetchingCostInfoForUri,
|
makeSelectFetchingCostInfoForUri,
|
||||||
} from "selectors/cost_info";
|
} from 'selectors/cost_info'
|
||||||
import FilePrice from "./view";
|
import {
|
||||||
|
makeSelectClaimForUri,
|
||||||
|
} from 'selectors/claims'
|
||||||
|
import FilePrice from './view'
|
||||||
|
|
||||||
const makeSelect = () => {
|
const makeSelect = () => {
|
||||||
const selectCostInfoForUri = makeSelectCostInfoForUri();
|
const selectCostInfoForUri = makeSelectCostInfoForUri();
|
||||||
const selectFetchingCostInfoForUri = makeSelectFetchingCostInfoForUri();
|
const selectFetchingCostInfoForUri = makeSelectFetchingCostInfoForUri();
|
||||||
|
const selectClaim = makeSelectClaimForUri();
|
||||||
|
|
||||||
const select = (state, props) => ({
|
const select = (state, props) => ({
|
||||||
costInfo: selectCostInfoForUri(state, props),
|
costInfo: selectCostInfoForUri(state, props),
|
||||||
fetching: selectFetchingCostInfoForUri(state, props),
|
fetching: selectFetchingCostInfoForUri(state, props),
|
||||||
|
claim: selectClaim(state, props),
|
||||||
});
|
});
|
||||||
|
|
||||||
return select;
|
return select;
|
||||||
|
|
|
@ -11,9 +11,15 @@ class FilePrice extends React.Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
fetchCost(props) {
|
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);
|
fetchCostInfo(uri);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue