Merge pull request #2744 from zxawry/minor-fixes
do not show block button on own channels
This commit is contained in:
commit
b7675a02a5
2 changed files with 26 additions and 16 deletions
|
@ -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),
|
||||
});
|
||||
|
||||
|
|
|
@ -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);
|
||||
}}
|
||||
/>
|
||||
)
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue