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

29 lines
959 B
JavaScript
Raw Normal View History

2020-12-03 18:29:47 +01:00
import { connect } from 'react-redux';
import { doResolveUris, makeSelectClaimForUri, makeSelectIsUriResolving, parseURI } from 'lbry-redux';
2020-12-03 18:29:47 +01:00
import { makeSelectWinningUriForQuery } from 'redux/selectors/search';
import WunderbarTopSuggestion from './view';
const select = (state, props) => {
const uriFromQuery = `lbry://${props.query}`;
let uris = [uriFromQuery];
try {
const { isChannel } = parseURI(uriFromQuery);
if (!isChannel) {
2020-12-03 22:06:54 +01:00
const channelUriFromQuery = `lbry://@${props.query}`;
uris.push(channelUriFromQuery);
}
} catch (e) {}
const resolvingUris = uris.some(uri => makeSelectIsUriResolving(uri)(state));
2020-12-03 18:29:47 +01:00
const winningUri = makeSelectWinningUriForQuery(props.query)(state);
const winningClaim = winningUri ? makeSelectClaimForUri(winningUri)(state) : undefined;
return { resolvingUris, winningUri, winningClaim, uris };
2020-12-03 18:29:47 +01:00
};
export default connect(select, {
doResolveUris,
})(WunderbarTopSuggestion);