lbry-desktop/ui/component/wunderbarTopSuggestion/index.js
zeppi ee9f63a161 integrate all the things
bugfix

wip

flow

fix

cleaning

clean
2021-10-15 23:49:41 -04:00

36 lines
1.2 KiB
JavaScript

import { connect } from 'react-redux';
import {
makeSelectClaimForUri,
makeSelectIsUriResolving,
makeSelectTagInClaimOrChannelForUri,
} from 'redux/selectors/claims';
import { doResolveUris } from 'redux/actions/claims';
import { parseURI } from 'util/lbryURI';
import { makeSelectWinningUriForQuery } from 'redux/selectors/search';
import WunderbarTopSuggestion from './view';
import { PREFERENCE_EMBED } from 'constants/tags';
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;
const preferEmbed = makeSelectTagInClaimOrChannelForUri(winningUri, PREFERENCE_EMBED)(state);
return { resolvingUris, winningUri, winningClaim, uris, preferEmbed };
};
export default connect(select, {
doResolveUris,
})(WunderbarTopSuggestion);