diff --git a/src/ui/component/channelLink/index.js b/src/ui/component/channelLink/index.js deleted file mode 100644 index b66a619e8..000000000 --- a/src/ui/component/channelLink/index.js +++ /dev/null @@ -1,40 +0,0 @@ -import { connect } from 'react-redux'; -import { THEME } from 'constants/settings'; -import { makeSelectClientSetting } from 'redux/selectors/settings'; - -import { - doResolveUri, - makeSelectClaimIsMine, - makeSelectTitleForUri, - makeSelectThumbnailForUri, - makeSelectClaimForUri, - makeSelectIsUriResolving, - makeSelectMetadataItemForUri, -} from 'lbry-redux'; - -import { selectBlackListedOutpoints } from 'lbryinc'; - -import ChannelLink from './view'; - -const select = (state, props) => { - return { - uri: props.uri, - claim: makeSelectClaimForUri(props.uri)(state), - title: makeSelectTitleForUri(props.uri)(state), - thumbnail: makeSelectThumbnailForUri(props.uri)(state), - description: makeSelectMetadataItemForUri(props.uri, 'description')(state), - currentTheme: makeSelectClientSetting(THEME)(state), - channelIsMine: makeSelectClaimIsMine(props.uri)(state), - isResolvingUri: makeSelectIsUriResolving(props.uri)(state), - blackListedOutpoints: selectBlackListedOutpoints(state), - }; -}; - -const perform = dispatch => ({ - resolveUri: uri => dispatch(doResolveUri(uri)), -}); - -export default connect( - select, - perform -)(ChannelLink); diff --git a/src/ui/component/channelLink/view.jsx b/src/ui/component/channelLink/view.jsx deleted file mode 100644 index 82eb38ee4..000000000 --- a/src/ui/component/channelLink/view.jsx +++ /dev/null @@ -1,123 +0,0 @@ -// @flow -import * as React from 'react'; -import Button from 'component/button'; -import ChannelTooltip from 'component/common/channel-tooltip'; -import uniqid from 'uniqid'; - -type Props = { - uri: string, - title: ?string, - claim: StreamClaim, - children: React.Node, - thumbnail: ?string, - description: ?string, - currentTheme: ?string, - isResolvingUri: boolean, - resolveUri: string => void, - blackListedOutpoints: Array<{ - txid: string, - nout: number, - }>, -}; - -type State = { - isTooltipActive: boolean, -}; - -class ChannelLink extends React.Component { - parentId: string; - buttonRef: { current: ?any }; - - static defaultProps = { - href: null, - title: null, - }; - - constructor(props: Props) { - super(props); - this.state = { isTooltipActive: false }; - - // The tooltip component don't work very well with refs, - // so we need to use an unique id for each link: - // (this: any).buttonRef = React.createRef(); - (this: any).parentId = uniqid.time('channnel-'); - } - - showTooltip = () => { - this.setState({ isTooltipActive: true }); - }; - - hideTooltip = () => { - this.setState({ isTooltipActive: false }); - }; - - isClaimBlackListed() { - const { claim, blackListedOutpoints } = this.props; - - if (claim && blackListedOutpoints) { - let blackListed = false; - - for (let i = 0; i < blackListedOutpoints.length; i += 1) { - const outpoint = blackListedOutpoints[i]; - if (outpoint.txid === claim.txid && outpoint.nout === claim.nout) { - blackListed = true; - break; - } - } - return blackListed; - } - } - - componentDidMount() { - const { isResolvingUri, resolveUri, claim, uri } = this.props; - if (!isResolvingUri && uri && !claim) { - resolveUri(uri); - } - } - - componentDidUpdate() { - const { isResolvingUri, resolveUri, claim, uri } = this.props; - if (!isResolvingUri && uri && !claim) { - resolveUri(uri); - } - } - - render() { - const { uri, claim, title, description, thumbnail, children, currentTheme, isResolvingUri } = this.props; - const isUnresolved = (!isResolvingUri && !claim) || !claim; - const isBlacklisted = this.isClaimBlackListed(); - - if (isBlacklisted || isUnresolved) { - return {children}; - } - - const { claim_id: claimId, name: channelName } = claim; - - return ( - -