changes after review

This commit is contained in:
jessop 2019-08-02 11:11:31 -04:00
parent ffbe3dcf8a
commit e1f2d8938b
8 changed files with 23 additions and 32 deletions

View file

@ -1,9 +1,10 @@
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { selectChannelIsBlocked, doToggleBlockChannel, doToast } from 'lbry-redux'; import { selectChannelIsBlocked, doToggleBlockChannel, doToast, 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),
shortUrl: makeSelectShortUrlForUri(props.uri)(state),
}); });
export default connect( export default connect(

View file

@ -7,6 +7,7 @@ import useHover from 'util/use-hover';
type Props = { type Props = {
uri: string, uri: string,
shortUrl: string,
isSubscribed: boolean, isSubscribed: boolean,
toggleBlockChannel: (uri: string) => void, toggleBlockChannel: (uri: string) => void,
channelIsBlocked: boolean, channelIsBlocked: boolean,
@ -14,7 +15,7 @@ type Props = {
}; };
export default function BlockButton(props: Props) { export default function BlockButton(props: Props) {
const { uri, toggleBlockChannel, channelIsBlocked, doToast } = props; const { uri, shortUrl, toggleBlockChannel, channelIsBlocked, doToast } = props;
const blockRef = useRef(); const blockRef = useRef();
const isHovering = useHover(blockRef); const isHovering = useHover(blockRef);
@ -25,13 +26,13 @@ export default function BlockButton(props: Props) {
<Button <Button
ref={blockRef} ref={blockRef}
iconColor="red" iconColor="red"
icon={blockedOverride ? ICONS.UNBLOCK : ICONS.BLOCK} icon={ICONS.BLOCK}
button={'alt'} button={'alt'}
label={blockedOverride || blockLabel} label={blockedOverride || blockLabel}
onClick={e => { onClick={e => {
e.stopPropagation(); e.stopPropagation();
if (!channelIsBlocked) { if (!channelIsBlocked) {
doToast({ message: `Blocked ${uri}`, linkText: 'Manage', linkTarget: `/${PAGES.BLOCKED}` }); doToast({ message: `Blocked ${shortUrl}`, linkText: 'Manage', linkTarget: `/${PAGES.BLOCKED}` });
} }
toggleBlockChannel(uri); toggleBlockChannel(uri);
}} }}

View file

@ -36,7 +36,7 @@ function ChannelContent(props: Props) {
{!fetching && channelIsBlocked && ( {!fetching && channelIsBlocked && (
<div className="card--section"> <div className="card--section">
<h2 className="card__content help">{__('You have blocked this channel content.')}</h2> <h2 className="help">{__('You have blocked this channel content.')}</h2>
</div> </div>
)} )}

View file

@ -19,15 +19,15 @@ function ChannelThumbnail(props: Props) {
const { channelName } = parseURI(uri); const { channelName } = parseURI(uri);
const initializer = channelName.charCodeAt(0) - 65; // will be between 0 and 57 const initializer = channelName.charCodeAt(0) - 65; // will be between 0 and 57
const colorClassName = `channel-thumbnail__default--${initializer % 4}`; const colorClassName = `channel-thumbnail__default--${initializer % 4}`;
const showThumb = !obscure && !!thumbnail;
return ( return (
<div <div
className={classnames('channel-thumbnail', className, { className={classnames('channel-thumbnail', className, {
[colorClassName]: !thumbnail, [colorClassName]: !showThumb,
})} })}
> >
{(!thumbnail || obscure) && <img className="channel-thumbnail__default" src={thumbnailPreview || Gerbil} />} {!showThumb && <img className="channel-thumbnail__default" src={thumbnailPreview || Gerbil} />}
{!obscure && thumbnail && <img className="channel-thumbnail__custom" src={thumbnailPreview || thumbnail} />} {showThumb && <img className="channel-thumbnail__custom" src={thumbnailPreview || thumbnail} />}
</div> </div>
); );
} }

View file

@ -107,6 +107,7 @@ function ClaimPreview(props: Props) {
shouldHide = blockedChannelUris.some(blockedUri => blockedUri === signingChannel.permanent_url); shouldHide = blockedChannelUris.some(blockedUri => blockedUri === signingChannel.permanent_url);
} }
// block channel claims if we can't control for them in claim search // block channel claims if we can't control for them in claim search
// e.g. fetchRecommendedSubscriptions
if (claim && isChannel && !shouldHide && !showUserBlocked && blockedChannelUris.length && isChannel) { if (claim && isChannel && !shouldHide && !showUserBlocked && blockedChannelUris.length && isChannel) {
shouldHide = blockedChannelUris.some(blockedUri => blockedUri === claim.permanent_url); shouldHide = blockedChannelUris.some(blockedUri => blockedUri === claim.permanent_url);
} }
@ -168,22 +169,12 @@ function ClaimPreview(props: Props) {
{claim ? <TruncatedText text={title || claim.name} lines={1} /> : <span>{__('Nothing here')}</span>} {claim ? <TruncatedText text={title || claim.name} lines={1} /> : <span>{__('Nothing here')}</span>}
</div> </div>
{!hideActions && ( {!hideActions && (
<div className={'claim-preview-actions'}> <div className={'card__actions'}>
{isChannel && !channelIsBlocked && ( {isChannel && !channelIsBlocked && (
<div className={'claim-preview__button'}> <SubscribeButton uri={uri.startsWith('lbry://') ? uri : `lbry://${uri}`} />
<SubscribeButton uri={uri.startsWith('lbry://') ? uri : `lbry://${uri}`} />
</div>
)}
{isChannel && !isSubscribed && (
<div className={'claim-preview__button'}>
<BlockButton uri={uri.startsWith('lbry://') ? uri : `lbry://${uri}`} />
</div>
)}
{!isChannel && (
<div className={'claim-preview__button'}>
<FileProperties uri={uri} />
</div>
)} )}
{isChannel && !isSubscribed && <BlockButton uri={uri.startsWith('lbry://') ? uri : `lbry://${uri}`} />}
{!isChannel && <FileProperties uri={uri} />}
</div> </div>
)} )}
</div> </div>

View file

@ -11,7 +11,7 @@ function ListBlocked(props: Props) {
const { uris } = props; const { uris } = props;
return ( return (
<Page notContained> <Page>
{uris && uris.length ? ( {uris && uris.length ? (
<div className="card"> <div className="card">
<ClaimList <ClaimList
@ -25,9 +25,8 @@ function ListBlocked(props: Props) {
) : ( ) : (
<div className="main--empty"> <div className="main--empty">
<section className="card card--section"> <section className="card card--section">
<header className="card__header"> <h2 className="card__title">{__('You arent blocking any channels')}</h2>
<h2 className="card__title">{__('It looks like you have no blocked channels.')}</h2> <p className="card__subtitle">When you block a channel, all content from that channel will be hidden.</p>
</header>
</section> </section>
</div> </div>
)} )}

View file

@ -8,7 +8,7 @@ import {
notificationsReducer, notificationsReducer,
tagsReducer, tagsReducer,
commentReducer, commentReducer,
blockChannelReducer, blockedReducer,
publishReducer, publishReducer,
} from 'lbry-redux'; } from 'lbry-redux';
import { import {
@ -26,7 +26,6 @@ import contentReducer from 'redux/reducers/content';
import settingsReducer from 'redux/reducers/settings'; import settingsReducer from 'redux/reducers/settings';
import subscriptionsReducer from 'redux/reducers/subscriptions'; import subscriptionsReducer from 'redux/reducers/subscriptions';
export default history => export default history =>
combineReducers({ combineReducers({
router: connectRouter(history), router: connectRouter(history),
@ -48,7 +47,7 @@ export default history =>
stats: statsReducer, stats: statsReducer,
subscriptions: subscriptionsReducer, subscriptions: subscriptionsReducer,
tags: tagsReducer, tags: tagsReducer,
blockedChannels: blockChannelReducer, blocked: blockedReducer,
user: userReducer, user: userReducer,
wallet: walletReducer, wallet: walletReducer,
}); });

View file

@ -48,7 +48,7 @@ const appFilter = createFilter('app', ['hasClickedComment', 'searchOptionsExpand
const walletFilter = createFilter('wallet', ['receiveAddress']); const walletFilter = createFilter('wallet', ['receiveAddress']);
const searchFilter = createFilter('search', ['options']); const searchFilter = createFilter('search', ['options']);
const tagsFilter = createFilter('tags', ['followedTags']); const tagsFilter = createFilter('tags', ['followedTags']);
const blockedFilter = createFilter('blockedChannels', ['blockedChannels']); const blockedFilter = createFilter('blocked', ['blockedChannels']);
const whiteListedReducers = [ const whiteListedReducers = [
// @if TARGET='app' // @if TARGET='app'
'publish', 'publish',
@ -60,7 +60,7 @@ const whiteListedReducers = [
'app', 'app',
'search', 'search',
'tags', 'tags',
'blockedChannels', 'blocked',
]; ];
const transforms = [ const transforms = [