Store claims by claim_id and fileinfo by sd_hash #192

Merged
6ea86b96 merged 5 commits from claims-by-id into master 2017-06-07 17:09:39 +02:00
3 changed files with 16 additions and 19 deletions
Showing only changes of commit c023a41a28 - Show all commits

View file

@ -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({

View file

@ -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;

View file

@ -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);
}
}