lbry-desktop/ui/component/claimProperties/index.js
infinite-persistence 6f8758c819
Fix and optimize makeSelectIsSubscribed (#273)
## Issues with `makeSelectIsSubscribed`
- It will not return true if the uri provided is canonical, because the compared subscription uri is in permanent form. This was causing certain elements like the Heart to not appear in claim tiles.
- It is super slow for large subscriptions not just because of the array size + being a hot selector, but also because it is looking up the claim twice (not memo'd) and also calling `parseURI` to determine if it's a channel, which is unnecessary if you already have the claim.

## Changes
- Optimize the selector to only look up the claim once, and make operations using already-obtained info.
2021-11-12 09:47:07 -05:00

16 lines
518 B
JavaScript

import { connect } from 'react-redux';
import { selectClaimIsMine, selectClaimForUri } from 'redux/selectors/claims';
import { selectIsSubscribedForUri } from 'redux/selectors/subscriptions';
import ClaimProperties from './view';
const select = (state, props) => {
const claim = selectClaimForUri(state, props.uri);
return {
claim,
isSubscribed: selectIsSubscribedForUri(state, props.uri),
claimIsMine: selectClaimIsMine(state, claim),
};
};
export default connect(select, null)(ClaimProperties);