lbry-desktop/ui/component/claimLink/index.js

34 lines
1 KiB
JavaScript
Raw Permalink Normal View History

2019-06-09 08:57:51 +02:00
import { connect } from 'react-redux';
import { doResolveUri, makeSelectClaimForUri, makeSelectIsUriResolving } from 'lbry-redux';
import { doSetPlayingUri } from 'redux/actions/content';
2021-10-01 18:00:57 +02:00
import { punctuationMarks } from 'util/remark-lbry';
2019-06-09 08:57:51 +02:00
import { selectBlackListedOutpoints } from 'lbryinc';
import { selectPlayingUri } from 'redux/selectors/content';
2019-06-09 08:57:51 +02:00
import ClaimLink from './view';
const select = (state, props) => {
let uri = props.uri;
let claim;
function getValidClaim(testUri) {
claim = makeSelectClaimForUri(testUri)(state);
2021-10-01 18:00:57 +02:00
if (claim === null && punctuationMarks.includes(testUri.charAt(testUri.length - 1))) {
getValidClaim(testUri.substring(0, testUri.length - 1));
} else {
uri = testUri;
}
}
getValidClaim(uri);
2019-06-09 08:57:51 +02:00
return {
uri,
claim,
fullUri: props.uri,
isResolvingUri: makeSelectIsUriResolving(uri)(state),
2019-06-09 08:57:51 +02:00
blackListedOutpoints: selectBlackListedOutpoints(state),
playingUri: selectPlayingUri(state),
2019-06-09 08:57:51 +02:00
};
};
export default connect(select, { doResolveUri, doSetPlayingUri })(ClaimLink);