Fix resolving uris in file tile
This commit is contained in:
parent
c023a41a28
commit
72137f51d2
3 changed files with 20 additions and 6 deletions
|
@ -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() {
|
||||
|
|
|
@ -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, {
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue