From cde0c0b2a80d5ae5b3402ce166f1ccc90d75e9c7 Mon Sep 17 00:00:00 2001 From: infinite-persistence Date: Mon, 23 May 2022 14:41:20 +0800 Subject: [PATCH] ClaimPreview: restructure Try to gather the hide/show logic --- ui/component/claimPreview/view.jsx | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/ui/component/claimPreview/view.jsx b/ui/component/claimPreview/view.jsx index c90a22e5f..97eaed28a 100644 --- a/ui/component/claimPreview/view.jsx +++ b/ui/component/claimPreview/view.jsx @@ -215,6 +215,7 @@ const ClaimPreview = forwardRef((props: Props, ref: any) => { ? claim.permanent_url || claim.canonical_url : undefined; const repostedContentUri = claim && (claim.reposted_claim ? claim.reposted_claim.permanent_url : claim.permanent_url); + const isPublishSuggestion = placeholder === 'publish' && !claim && uri.startsWith('lbry://@'); // See commit a43d9150. // Get channel title ( use name as fallback ) let channelTitle = null; @@ -227,10 +228,9 @@ const ClaimPreview = forwardRef((props: Props, ref: any) => { } } - // Aria-label value for claim preview - let ariaLabelData = isChannelUri ? title : formatClaimPreviewTitle(title, channelTitle, date, mediaDuration); + const ariaLabelData = isChannelUri ? title : formatClaimPreviewTitle(title, channelTitle, date, mediaDuration); - let navigateUrl = formatLbryUrlForWeb((claim && claim.canonical_url) || uri || '/'); + const navigateUrl = formatLbryUrlForWeb((claim && claim.canonical_url) || uri || '/'); let navigateSearch = new URLSearchParams(); if (listId) { navigateSearch.set(COLLECTIONS_CONSTS.COLLECTION_ID, listId); @@ -273,12 +273,19 @@ const ClaimPreview = forwardRef((props: Props, ref: any) => { shouldHide = true; } + if (!shouldHide && isPublishSuggestion) { + shouldHide = true; + } + if (!shouldHide && customShouldHide && claim) { if (customShouldHide(claim)) { shouldHide = true; } } + // ************************************************************************** + // ************************************************************************** + // Weird placement warning // Make sure this happens after we figure out if this claim needs to be hidden const thumbnailUrl = useGetThumbnail(uri, claim, streamingUrl, getFile, shouldHide); @@ -307,6 +314,9 @@ const ClaimPreview = forwardRef((props: Props, ref: any) => { } }, [isValid, uri, isResolvingUri, shouldFetch, resolveUri]); + // ************************************************************************** + // ************************************************************************** + if ((shouldHide && !showNullPlaceholder) || (isLivestream && !ENABLE_NO_SOURCE_CLAIMS)) { return null; } @@ -340,8 +350,9 @@ const ClaimPreview = forwardRef((props: Props, ref: any) => { ); } - if (placeholder === 'publish' && !claim && uri.startsWith('lbry://@')) { - return null; + + if (isPublishSuggestion) { + return null; // Ignore 'showNullPlaceholder' } let liveProperty = null;