2019-06-09 08:57:51 +02:00
|
|
|
import { connect } from 'react-redux';
|
2021-10-08 05:47:39 +02:00
|
|
|
import { makeSelectClaimForUri, makeSelectIsUriResolving } from 'redux/selectors/claims';
|
|
|
|
import { doResolveUri } from 'redux/actions/claims';
|
2021-09-30 23:30:32 +02:00
|
|
|
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';
|
2020-10-20 19:10:02 +02:00
|
|
|
import { selectPlayingUri } from 'redux/selectors/content';
|
2019-06-09 08:57:51 +02:00
|
|
|
import ClaimLink from './view';
|
|
|
|
|
|
|
|
const select = (state, props) => {
|
2021-09-30 23:30:32 +02:00
|
|
|
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))) {
|
2021-09-30 23:30:32 +02:00
|
|
|
getValidClaim(testUri.substring(0, testUri.length - 1));
|
|
|
|
} else {
|
|
|
|
uri = testUri;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
getValidClaim(uri);
|
|
|
|
|
2019-06-09 08:57:51 +02:00
|
|
|
return {
|
2021-09-30 23:30:32 +02:00
|
|
|
uri,
|
|
|
|
claim,
|
|
|
|
fullUri: props.uri,
|
|
|
|
isResolvingUri: makeSelectIsUriResolving(uri)(state),
|
2019-06-09 08:57:51 +02:00
|
|
|
blackListedOutpoints: selectBlackListedOutpoints(state),
|
2020-10-20 19:10:02 +02:00
|
|
|
playingUri: selectPlayingUri(state),
|
2019-06-09 08:57:51 +02:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2021-09-30 23:30:32 +02:00
|
|
|
export default connect(select, { doResolveUri, doSetPlayingUri })(ClaimLink);
|