Merge pull request #2744 from zxawry/minor-fixes

do not show block button on own channels
This commit is contained in:
Sean Yesmunt 2019-08-18 13:30:50 -04:00 committed by GitHub
commit b7675a02a5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 26 additions and 16 deletions

View file

@ -1,9 +1,16 @@
import { connect } from 'react-redux';
import { selectChannelIsBlocked, doToggleBlockChannel, doToast, makeSelectShortUrlForUri } from 'lbry-redux';
import {
selectChannelIsBlocked,
doToggleBlockChannel,
doToast,
makeSelectClaimIsMine,
makeSelectShortUrlForUri,
} from 'lbry-redux';
import BlockButton from './view';
const select = (state, props) => ({
channelIsBlocked: selectChannelIsBlocked(props.uri)(state),
claimIsMine: makeSelectClaimIsMine(props.uri)(state),
shortUrl: makeSelectShortUrlForUri(props.uri)(state),
});

View file

@ -11,11 +11,12 @@ type Props = {
isSubscribed: boolean,
toggleBlockChannel: (uri: string) => void,
channelIsBlocked: boolean,
claimIsMine: boolean,
doToast: ({ message: string, linkText: string, linkTarget: string }) => void,
};
export default function BlockButton(props: Props) {
const { uri, shortUrl, toggleBlockChannel, channelIsBlocked, doToast } = props;
const { uri, shortUrl, toggleBlockChannel, channelIsBlocked, claimIsMine, doToast } = props;
const blockRef = useRef();
const isHovering = useHover(blockRef);
@ -23,19 +24,21 @@ export default function BlockButton(props: Props) {
const blockedOverride = channelIsBlocked && isHovering && __('Unblock');
return (
<Button
ref={blockRef}
iconColor="red"
icon={ICONS.BLOCK}
button={'alt'}
label={blockedOverride || blockLabel}
onClick={e => {
e.stopPropagation();
if (!channelIsBlocked) {
doToast({ message: `Blocked ${shortUrl}`, linkText: 'Manage', linkTarget: `/${PAGES.BLOCKED}` });
}
toggleBlockChannel(uri);
}}
/>
!claimIsMine && (
<Button
ref={blockRef}
iconColor="red"
icon={ICONS.BLOCK}
button={'alt'}
label={blockedOverride || blockLabel}
onClick={e => {
e.stopPropagation();
if (!channelIsBlocked) {
doToast({ message: `Blocked ${shortUrl}`, linkText: 'Manage', linkTarget: `/${PAGES.BLOCKED}` });
}
toggleBlockChannel(uri);
}}
/>
)
);
}