lbry-desktop/ui/component/wunderbarTopSuggestion/index.js
Sean Yesmunt 4e0e1e2f2b cleanup
2020-12-03 16:18:04 -05:00

28 lines
959 B
JavaScript

import { connect } from 'react-redux';
import { doResolveUris, makeSelectClaimForUri, makeSelectIsUriResolving, parseURI } from 'lbry-redux';
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) {
const channelUriFromQuery = `lbry://@${props.query}`;
uris.push(channelUriFromQuery);
}
} catch (e) {}
const resolvingUris = uris.some(uri => makeSelectIsUriResolving(uri)(state));
const winningUri = makeSelectWinningUriForQuery(props.query)(state);
const winningClaim = winningUri ? makeSelectClaimForUri(winningUri)(state) : undefined;
return { resolvingUris, winningUri, winningClaim, uris };
};
export default connect(select, {
doResolveUris,
})(WunderbarTopSuggestion);