mirror of
https://github.com/LBRYFoundation/lbry-desktop.git
synced 2025-08-30 00:41:24 +00:00
blocked channels are filtered from claim search and images are obscured
This commit is contained in:
parent
5ab165131f
commit
5c61a1de0e
8 changed files with 40 additions and 9 deletions
|
@ -9,10 +9,11 @@ type Props = {
|
||||||
uri: string,
|
uri: string,
|
||||||
className?: string,
|
className?: string,
|
||||||
thumbnailPreview: ?string,
|
thumbnailPreview: ?string,
|
||||||
|
obscure?: boolean,
|
||||||
};
|
};
|
||||||
|
|
||||||
function ChannelThumbnail(props: Props) {
|
function ChannelThumbnail(props: Props) {
|
||||||
const { thumbnail, uri, className, thumbnailPreview } = props;
|
const { thumbnail, uri, className, thumbnailPreview, obscure } = props;
|
||||||
|
|
||||||
// Generate a random color class based on the first letter of the channel name
|
// Generate a random color class based on the first letter of the channel name
|
||||||
const { channelName } = parseURI(uri);
|
const { channelName } = parseURI(uri);
|
||||||
|
@ -25,8 +26,8 @@ function ChannelThumbnail(props: Props) {
|
||||||
[colorClassName]: !thumbnail,
|
[colorClassName]: !thumbnail,
|
||||||
})}
|
})}
|
||||||
>
|
>
|
||||||
{!thumbnail && <img className="channel-thumbnail__default" src={thumbnailPreview || Gerbil} />}
|
{(!thumbnail || obscure) && <img className="channel-thumbnail__default" src={thumbnailPreview || Gerbil} />}
|
||||||
{thumbnail && <img className="channel-thumbnail__custom" src={thumbnailPreview || thumbnail} />}
|
{!obscure && thumbnail && <img className="channel-thumbnail__custom" src={thumbnailPreview || thumbnail} />}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,6 +26,7 @@ type Props = {
|
||||||
id?: string,
|
id?: string,
|
||||||
// If using the default header, this is a unique ID needed to persist the state of the filter setting
|
// If using the default header, this is a unique ID needed to persist the state of the filter setting
|
||||||
persistedStorageKey?: string,
|
persistedStorageKey?: string,
|
||||||
|
showHiddenByUser: boolean,
|
||||||
};
|
};
|
||||||
|
|
||||||
export default function ClaimList(props: Props) {
|
export default function ClaimList(props: Props) {
|
||||||
|
@ -43,6 +44,7 @@ export default function ClaimList(props: Props) {
|
||||||
pageSize,
|
pageSize,
|
||||||
page,
|
page,
|
||||||
id,
|
id,
|
||||||
|
showHiddenByUser,
|
||||||
} = props;
|
} = props;
|
||||||
const [scrollBottomCbMap, setScrollBottomCbMap] = useState({});
|
const [scrollBottomCbMap, setScrollBottomCbMap] = useState({});
|
||||||
const [currentSort, setCurrentSort] = usePersistedState(persistedStorageKey, SORT_NEW);
|
const [currentSort, setCurrentSort] = usePersistedState(persistedStorageKey, SORT_NEW);
|
||||||
|
@ -113,7 +115,7 @@ export default function ClaimList(props: Props) {
|
||||||
<ul className="ul--no-style">
|
<ul className="ul--no-style">
|
||||||
{sortedUris.map((uri, index) => (
|
{sortedUris.map((uri, index) => (
|
||||||
<React.Fragment key={uri}>
|
<React.Fragment key={uri}>
|
||||||
<ClaimPreview uri={uri} type={type} />
|
<ClaimPreview uri={uri} type={type} showUserBlocked={showHiddenByUser} />
|
||||||
{index === 4 && injectedItem && injectedItem}
|
{index === 4 && injectedItem && injectedItem}
|
||||||
</React.Fragment>
|
</React.Fragment>
|
||||||
))}
|
))}
|
||||||
|
|
|
@ -1,6 +1,12 @@
|
||||||
import * as SETTINGS from 'constants/settings';
|
import * as SETTINGS from 'constants/settings';
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
import { doClaimSearch, selectClaimSearchByQuery, selectFetchingClaimSearch, doToggleTagFollow } from 'lbry-redux';
|
import {
|
||||||
|
doClaimSearch,
|
||||||
|
selectClaimSearchByQuery,
|
||||||
|
selectFetchingClaimSearch,
|
||||||
|
doToggleTagFollow,
|
||||||
|
selectBlockedChannels,
|
||||||
|
} from 'lbry-redux';
|
||||||
import { selectSubscriptions } from 'redux/selectors/subscriptions';
|
import { selectSubscriptions } from 'redux/selectors/subscriptions';
|
||||||
import { makeSelectClientSetting } from 'redux/selectors/settings';
|
import { makeSelectClientSetting } from 'redux/selectors/settings';
|
||||||
import ClaimListDiscover from './view';
|
import ClaimListDiscover from './view';
|
||||||
|
@ -10,6 +16,7 @@ const select = state => ({
|
||||||
loading: selectFetchingClaimSearch(state),
|
loading: selectFetchingClaimSearch(state),
|
||||||
subscribedChannels: selectSubscriptions(state),
|
subscribedChannels: selectSubscriptions(state),
|
||||||
showNsfw: makeSelectClientSetting(SETTINGS.SHOW_NSFW)(state),
|
showNsfw: makeSelectClientSetting(SETTINGS.SHOW_NSFW)(state),
|
||||||
|
hiddenUris: selectBlockedChannels(state),
|
||||||
});
|
});
|
||||||
|
|
||||||
const perform = {
|
const perform = {
|
||||||
|
|
|
@ -44,6 +44,7 @@ type Props = {
|
||||||
claimSearchByQuery: {
|
claimSearchByQuery: {
|
||||||
[string]: Array<string>,
|
[string]: Array<string>,
|
||||||
},
|
},
|
||||||
|
hiddenUris: Array<string>,
|
||||||
};
|
};
|
||||||
|
|
||||||
function ClaimListDiscover(props: Props) {
|
function ClaimListDiscover(props: Props) {
|
||||||
|
@ -59,6 +60,7 @@ function ClaimListDiscover(props: Props) {
|
||||||
showNsfw,
|
showNsfw,
|
||||||
history,
|
history,
|
||||||
location,
|
location,
|
||||||
|
hiddenUris,
|
||||||
} = props;
|
} = props;
|
||||||
const didNavigateForward = history.action === 'PUSH';
|
const didNavigateForward = history.action === 'PUSH';
|
||||||
const { search, pathname } = location;
|
const { search, pathname } = location;
|
||||||
|
@ -75,6 +77,7 @@ function ClaimListDiscover(props: Props) {
|
||||||
no_totals: boolean,
|
no_totals: boolean,
|
||||||
any_tags: Array<string>,
|
any_tags: Array<string>,
|
||||||
channel_ids: Array<string>,
|
channel_ids: Array<string>,
|
||||||
|
not_channel_ids: Array<string>,
|
||||||
not_tags: Array<string>,
|
not_tags: Array<string>,
|
||||||
order_by: Array<string>,
|
order_by: Array<string>,
|
||||||
release_time?: string,
|
release_time?: string,
|
||||||
|
@ -86,6 +89,7 @@ function ClaimListDiscover(props: Props) {
|
||||||
no_totals: true,
|
no_totals: true,
|
||||||
any_tags: (personalView && personalSort === SEARCH_SORT_YOU) || !personalView ? tags : [],
|
any_tags: (personalView && personalSort === SEARCH_SORT_YOU) || !personalView ? tags : [],
|
||||||
channel_ids: personalSort === SEARCH_SORT_CHANNELS ? subscribedChannels.map(sub => sub.uri.split('#')[1]) : [],
|
channel_ids: personalSort === SEARCH_SORT_CHANNELS ? subscribedChannels.map(sub => sub.uri.split('#')[1]) : [],
|
||||||
|
not_channel_ids: hiddenUris && hiddenUris.length ? hiddenUris.map(hiddenUri => hiddenUri.split('#')[1]) : [],
|
||||||
not_tags: !showNsfw ? MATURE_TAGS : [],
|
not_tags: !showNsfw ? MATURE_TAGS : [],
|
||||||
order_by:
|
order_by:
|
||||||
typeSort === TYPE_TRENDING
|
typeSort === TYPE_TRENDING
|
||||||
|
|
|
@ -102,10 +102,14 @@ function ClaimPreview(props: Props) {
|
||||||
(outpoint.txid === claim.txid && outpoint.nout === claim.nout)
|
(outpoint.txid === claim.txid && outpoint.nout === claim.nout)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
// if showUserBlocked wasnt passed to claimPreview (for blocked page) hide user-blocked channels
|
// block stream claims
|
||||||
if (claim && !shouldHide && !showUserBlocked && blockedChannelUris.length && signingChannel) {
|
if (claim && !shouldHide && !showUserBlocked && blockedChannelUris.length && signingChannel) {
|
||||||
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
|
||||||
|
if (claim && isChannel && !shouldHide && !showUserBlocked && blockedChannelUris.length && isChannel) {
|
||||||
|
shouldHide = blockedChannelUris.some(blockedUri => blockedUri === claim.permanent_url);
|
||||||
|
}
|
||||||
|
|
||||||
function handleContextMenu(e) {
|
function handleContextMenu(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
@ -157,7 +161,7 @@ function ClaimPreview(props: Props) {
|
||||||
'claim-preview--pending': pending,
|
'claim-preview--pending': pending,
|
||||||
})}
|
})}
|
||||||
>
|
>
|
||||||
{isChannel ? <ChannelThumbnail uri={uri} /> : <CardMedia thumbnail={thumbnail} />}
|
{isChannel ? <ChannelThumbnail uri={uri} obscure={channelIsBlocked} /> : <CardMedia thumbnail={thumbnail} />}
|
||||||
<div className="claim-preview-metadata">
|
<div className="claim-preview-metadata">
|
||||||
<div className="claim-preview-info">
|
<div className="claim-preview-info">
|
||||||
<div className="claim-preview-title">
|
<div className="claim-preview-title">
|
||||||
|
|
|
@ -15,6 +15,7 @@ import ChannelThumbnail from 'component/channelThumbnail';
|
||||||
import ChannelEdit from 'component/channelEdit';
|
import ChannelEdit from 'component/channelEdit';
|
||||||
import ClaimUri from 'component/claimUri';
|
import ClaimUri from 'component/claimUri';
|
||||||
import * as ICONS from 'constants/icons';
|
import * as ICONS from 'constants/icons';
|
||||||
|
import classnames from 'classnames';
|
||||||
|
|
||||||
const PAGE_VIEW_QUERY = `view`;
|
const PAGE_VIEW_QUERY = `view`;
|
||||||
const ABOUT_PAGE = `about`;
|
const ABOUT_PAGE = `about`;
|
||||||
|
@ -77,11 +78,18 @@ function ChannelPage(props: Props) {
|
||||||
<Page>
|
<Page>
|
||||||
<div className="card">
|
<div className="card">
|
||||||
<header className="channel-cover">
|
<header className="channel-cover">
|
||||||
{!editing && cover && <img className="channel-cover__custom" src={cover} />}
|
{!editing && cover && (
|
||||||
|
<img
|
||||||
|
className={classnames('channel-cover__custom', { 'channel__image--blurred': channelIsBlocked })}
|
||||||
|
src={cover}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
{editing && <img className="channel-cover__custom" src={coverPreview} />}
|
{editing && <img className="channel-cover__custom" src={coverPreview} />}
|
||||||
{/* component that offers select/upload */}
|
{/* component that offers select/upload */}
|
||||||
<div className="channel__primary-info ">
|
<div className="channel__primary-info ">
|
||||||
{!editing && <ChannelThumbnail className="channel__thumbnail--channel-page" uri={uri} />}
|
{!editing && (
|
||||||
|
<ChannelThumbnail className="channel__thumbnail--channel-page" uri={uri} obscure={channelIsBlocked} />
|
||||||
|
)}
|
||||||
{editing && (
|
{editing && (
|
||||||
<ChannelThumbnail
|
<ChannelThumbnail
|
||||||
className="channel__thumbnail--channel-page"
|
className="channel__thumbnail--channel-page"
|
||||||
|
|
|
@ -19,6 +19,7 @@ function ListBlocked(props: Props) {
|
||||||
persistedStorageKey="block-list-published"
|
persistedStorageKey="block-list-published"
|
||||||
uris={uris}
|
uris={uris}
|
||||||
defaultSort
|
defaultSort
|
||||||
|
showHiddenByUser
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
) : (
|
) : (
|
||||||
|
|
|
@ -102,3 +102,7 @@ $metadata-z-index: 1;
|
||||||
color: rgba($lbry-white, 0.75);
|
color: rgba($lbry-white, 0.75);
|
||||||
margin-right: var(--spacing-large);
|
margin-right: var(--spacing-large);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.channel__image--blurred {
|
||||||
|
filter: blur(16px);
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue