Fix resolving uris in file tile

This commit is contained in:
6ea86b96 2017-06-05 15:48:06 +07:00
parent c023a41a28
commit 72137f51d2
3 changed files with 20 additions and 6 deletions

View file

@ -19,11 +19,15 @@ class FileTile extends React.Component {
}
componentDidMount() {
const { isResolvingUri, resolveUri, claim, uri } = this.props;
this.resolve(this.props);
}
if (!isResolvingUri && !claim && uri) {
resolveUri(uri);
}
componentWillReceiveProps(nextProps) {
this.resolve(nextProps);
}
resolve({ isResolvingUri, claim, uri, resolveUri }) {
if (!isResolvingUri && claim === undefined && uri) resolveUri(uri);
}
handleMouseOver() {

View file

@ -13,6 +13,8 @@ reducers[types.RESOLVE_URI_COMPLETED] = function(state, action) {
if (claim) {
byId[claim.claim_id] = claim;
byUri[uri] = claim.claim_id;
} else {
byUri[uri] = null;
}
return Object.assign({}, state, {

View file

@ -17,9 +17,17 @@ export const selectClaimsByUri = createSelector(
Object.keys(byUri).forEach(uri => {
const claimId = byUri[uri];
const claim = byId[claimId];
claims[uri] = claim;
// NOTE returning a null claim allows us to differentiate between an
// undefined (never fetched claim) and one which just doesn't exist. Not
// the cleanest solution but couldn't think of anything better right now
if (claimId === null) {
claims[uri] = null;
} else {
const claim = byId[claimId];
claims[uri] = claim;
}
})
return claims;