mirror of
https://github.com/LBRYFoundation/lbry-desktop.git
synced 2025-09-01 09:45:10 +00:00
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 { 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';
|
import BlockButton from './view';
|
||||||
|
|
||||||
const select = (state, props) => ({
|
const select = (state, props) => ({
|
||||||
channelIsBlocked: selectChannelIsBlocked(props.uri)(state),
|
channelIsBlocked: selectChannelIsBlocked(props.uri)(state),
|
||||||
|
claimIsMine: makeSelectClaimIsMine(props.uri)(state),
|
||||||
shortUrl: makeSelectShortUrlForUri(props.uri)(state),
|
shortUrl: makeSelectShortUrlForUri(props.uri)(state),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -11,11 +11,12 @@ type Props = {
|
||||||
isSubscribed: boolean,
|
isSubscribed: boolean,
|
||||||
toggleBlockChannel: (uri: string) => void,
|
toggleBlockChannel: (uri: string) => void,
|
||||||
channelIsBlocked: boolean,
|
channelIsBlocked: boolean,
|
||||||
|
claimIsMine: boolean,
|
||||||
doToast: ({ message: string, linkText: string, linkTarget: string }) => void,
|
doToast: ({ message: string, linkText: string, linkTarget: string }) => void,
|
||||||
};
|
};
|
||||||
|
|
||||||
export default function BlockButton(props: Props) {
|
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 blockRef = useRef();
|
||||||
const isHovering = useHover(blockRef);
|
const isHovering = useHover(blockRef);
|
||||||
|
@ -23,19 +24,21 @@ export default function BlockButton(props: Props) {
|
||||||
const blockedOverride = channelIsBlocked && isHovering && __('Unblock');
|
const blockedOverride = channelIsBlocked && isHovering && __('Unblock');
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Button
|
!claimIsMine && (
|
||||||
ref={blockRef}
|
<Button
|
||||||
iconColor="red"
|
ref={blockRef}
|
||||||
icon={ICONS.BLOCK}
|
iconColor="red"
|
||||||
button={'alt'}
|
icon={ICONS.BLOCK}
|
||||||
label={blockedOverride || blockLabel}
|
button={'alt'}
|
||||||
onClick={e => {
|
label={blockedOverride || blockLabel}
|
||||||
e.stopPropagation();
|
onClick={e => {
|
||||||
if (!channelIsBlocked) {
|
e.stopPropagation();
|
||||||
doToast({ message: `Blocked ${shortUrl}`, linkText: 'Manage', linkTarget: `/${PAGES.BLOCKED}` });
|
if (!channelIsBlocked) {
|
||||||
}
|
doToast({ message: `Blocked ${shortUrl}`, linkText: 'Manage', linkTarget: `/${PAGES.BLOCKED}` });
|
||||||
toggleBlockChannel(uri);
|
}
|
||||||
}}
|
toggleBlockChannel(uri);
|
||||||
/>
|
}}
|
||||||
|
/>
|
||||||
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue