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

View file

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

View file

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