diff --git a/ui/component/channelSelector/view.jsx b/ui/component/channelSelector/view.jsx index 9fd5558d8..fa5bd08d0 100644 --- a/ui/component/channelSelector/view.jsx +++ b/ui/component/channelSelector/view.jsx @@ -30,7 +30,7 @@ function ChannelListItem(props: ListItemProps) { return (
- + {isSelected && }
diff --git a/ui/component/channelThumbnail/transparent_1x1.png b/ui/component/channelThumbnail/transparent_1x1.png deleted file mode 100644 index fdf950d0d..000000000 Binary files a/ui/component/channelThumbnail/transparent_1x1.png and /dev/null differ diff --git a/ui/component/channelThumbnail/view.jsx b/ui/component/channelThumbnail/view.jsx index fa89e839f..7f3c97b80 100644 --- a/ui/component/channelThumbnail/view.jsx +++ b/ui/component/channelThumbnail/view.jsx @@ -3,11 +3,14 @@ import React from 'react'; import { parseURI } from 'lbry-redux'; import classnames from 'classnames'; import Gerbil from './gerbil.png'; -import Transparent from './transparent_1x1.png'; import FreezeframeWrapper from 'component/fileThumbnail/FreezeframeWrapper'; import ChannelStakedIndicator from 'component/channelStakedIndicator'; import { getThumbnailCdnUrl } from 'util/thumbnail'; -import useLazyLoading from 'effects/use-lazy-loading'; + +const FONT_PX = 16.0; +const IMG_XSMALL_REM = 2.1; +const IMG_SMALL_REM = 3.0; +const IMG_NORMAL_REM = 10.0; type Props = { thumbnail: ?string, @@ -16,14 +19,14 @@ type Props = { thumbnailPreview: ?string, obscure?: boolean, small?: boolean, + xsmall?: boolean, allowGifs?: boolean, claim: ?ChannelClaim, doResolveUri: (string) => void, isResolving: boolean, showDelayedMessage?: boolean, + noLazyLoad?: boolean, hideStakedIndicator?: boolean, - xsmall?: boolean, - noOptimization?: boolean, }; function ChannelThumbnail(props: Props) { @@ -40,8 +43,8 @@ function ChannelThumbnail(props: Props) { doResolveUri, isResolving, showDelayedMessage = false, + noLazyLoad, hideStakedIndicator = false, - noOptimization, } = props; const [thumbError, setThumbError] = React.useState(false); const shouldResolve = claim === undefined; @@ -51,6 +54,8 @@ function ChannelThumbnail(props: Props) { const isGif = channelThumbnail && channelThumbnail.endsWith('gif'); const showThumb = (!obscure && !!thumbnail) || thumbnailPreview; const thumbnailRef = React.useRef(null); + const thumbnailSize = calcRenderedImgWidth(); // currently always 1:1 + // Generate a random color class based on the first letter of the channel name const { channelName } = parseURI(uri); let initializer; @@ -62,14 +67,26 @@ function ChannelThumbnail(props: Props) { colorClassName = `channel-thumbnail__default--4`; } + function calcRenderedImgWidth() { + let rem; + if (xsmall) { + rem = IMG_XSMALL_REM; + } else if (small) { + rem = IMG_SMALL_REM; + } else { + rem = IMG_NORMAL_REM; + } + + const devicePixelRatio = window.devicePixelRatio || 1.0; + return Math.ceil(rem * devicePixelRatio * FONT_PX); + } + React.useEffect(() => { if (shouldResolve && uri) { doResolveUri(uri); } }, [doResolveUri, shouldResolve, uri]); - useLazyLoading(thumbnailRef, 0.25, [showThumb, thumbError, channelThumbnail]); - if (isGif && !allowGifs) { return ( @@ -81,8 +98,8 @@ function ChannelThumbnail(props: Props) { let url = channelThumbnail; // @if TARGET='web' // Pass image urls through a compression proxy, except for GIFs. - if (thumbnail && !noOptimization && !(isGif && allowGifs)) { - url = getThumbnailCdnUrl({ thumbnail }); + if (thumbnail && !(isGif && allowGifs)) { + url = getThumbnailCdnUrl({ thumbnail, width: thumbnailSize, height: thumbnailSize, quality: 85 }); } // @endif @@ -100,8 +117,10 @@ function ChannelThumbnail(props: Props) { ref={thumbnailRef} alt={__('Channel profile picture')} className="channel-thumbnail__default" - data-src={!thumbError && url ? url : Gerbil} - src={Transparent} + src={!thumbError && url ? url : Gerbil} + width={thumbnailSize} + height={thumbnailSize} + loading={noLazyLoad ? undefined : 'lazy'} onError={() => setThumbError(true)} // if thumb fails (including due to https replace, show gerbil. /> )} @@ -114,8 +133,10 @@ function ChannelThumbnail(props: Props) { ref={thumbnailRef} alt={__('Channel profile picture')} className="channel-thumbnail__custom" - data-src={!thumbError && url ? url : Gerbil} - src={Transparent} + src={!thumbError && url ? url : Gerbil} + width={thumbnailSize} + height={thumbnailSize} + loading={noLazyLoad ? undefined : 'lazy'} onError={() => setThumbError(true)} // if thumb fails (including due to https replace, show gerbil. /> )} diff --git a/ui/component/claimPreview/view.jsx b/ui/component/claimPreview/view.jsx index cb0d6feae..bba5c1310 100644 --- a/ui/component/claimPreview/view.jsx +++ b/ui/component/claimPreview/view.jsx @@ -300,7 +300,7 @@ const ClaimPreview = forwardRef((props: Props, ref: any) => { > {isChannelUri && claim ? ( - + ) : ( <> @@ -404,7 +404,7 @@ const ClaimPreview = forwardRef((props: Props, ref: any) => {
{!isChannelUri && signingChannel && (
- +
)} diff --git a/ui/component/claimPreviewTile/view.jsx b/ui/component/claimPreviewTile/view.jsx index 5903e6f1b..810cd1fa9 100644 --- a/ui/component/claimPreviewTile/view.jsx +++ b/ui/component/claimPreviewTile/view.jsx @@ -226,7 +226,7 @@ function ClaimPreviewTile(props: Props) { ) : ( - +
diff --git a/ui/component/comment/view.jsx b/ui/component/comment/view.jsx index 735ad4acf..421e4f7b4 100644 --- a/ui/component/comment/view.jsx +++ b/ui/component/comment/view.jsx @@ -182,9 +182,9 @@ function Comment(props: Props) { >
{authorUri ? ( - + ) : ( - + )}
diff --git a/ui/component/commentMenuList/view.jsx b/ui/component/commentMenuList/view.jsx index d8c7ce563..31fc09035 100644 --- a/ui/component/commentMenuList/view.jsx +++ b/ui/component/commentMenuList/view.jsx @@ -218,7 +218,7 @@ function CommentMenuList(props: Props) { {activeChannelClaim && (
- +
{__('Interacting as %channelName%', { channelName: activeChannelClaim.name })}
diff --git a/ui/component/commentReactions/view.jsx b/ui/component/commentReactions/view.jsx index 4dc2c50d9..ba38f9d7d 100644 --- a/ui/component/commentReactions/view.jsx +++ b/ui/component/commentReactions/view.jsx @@ -105,7 +105,9 @@ export default function CommentReactions(props: Props) { className={classnames('comment__action comment__action--creator-like')} onClick={() => react(commentId, REACTION_TYPES.CREATOR_LIKE)} > - {creatorLiked && } + {creatorLiked && ( + + )} )} diff --git a/ui/component/header/view.jsx b/ui/component/header/view.jsx index 09c354d5f..cf1cea516 100644 --- a/ui/component/header/view.jsx +++ b/ui/component/header/view.jsx @@ -319,7 +319,7 @@ const Header = (props: Props) => { // @endif > {activeChannelUrl ? ( - + ) : ( )} diff --git a/ui/component/sideNavigation/view.jsx b/ui/component/sideNavigation/view.jsx index 01a64bdb8..7d4cdc9a3 100644 --- a/ui/component/sideNavigation/view.jsx +++ b/ui/component/sideNavigation/view.jsx @@ -485,7 +485,7 @@ function SubscriptionListItem({ subscription }: { subscription: Subscription }) className="navigation-link navigation-link--with-thumbnail" activeClass="navigation-link--active" > - + {channelName} diff --git a/ui/component/wunderbarSuggestion/view.jsx b/ui/component/wunderbarSuggestion/view.jsx index abe6287cb..b81c50622 100644 --- a/ui/component/wunderbarSuggestion/view.jsx +++ b/ui/component/wunderbarSuggestion/view.jsx @@ -40,7 +40,7 @@ export default function WunderbarSuggestion(props: Props) { 'wunderbar__suggestion--channel': isChannel, })} > - {isChannel && } + {isChannel && } {!isChannel && ( {/* @if TARGET='app' */} diff --git a/ui/modal/modalPublishPreview/view.jsx b/ui/modal/modalPublishPreview/view.jsx index eb7a2320b..3ffdbd8e2 100644 --- a/ui/modal/modalPublishPreview/view.jsx +++ b/ui/modal/modalPublishPreview/view.jsx @@ -199,7 +199,7 @@ const ModalPublishPreview = (props: Props) => { const channelClaim = myChannels && myChannels.find((x) => x.name === channel); return channel ? (
- {channelClaim && } + {channelClaim && } {channel}
) : ( diff --git a/ui/page/channel/view.jsx b/ui/page/channel/view.jsx index 9e2e8a1f7..8e0d21ed4 100644 --- a/ui/page/channel/view.jsx +++ b/ui/page/channel/view.jsx @@ -185,13 +185,7 @@ function ChannelPage(props: Props) {
{cover && }
- +

{title || '@' + channelName}