ClaimPreview: restructure

Try to gather the hide/show logic
This commit is contained in:
infinite-persistence 2022-05-23 14:41:20 +08:00
parent 287eb38e7a
commit cde0c0b2a8
No known key found for this signature in database
GPG key ID: B9C3252EDC3D0AA0

View file

@ -215,6 +215,7 @@ const ClaimPreview = forwardRef<any, {}>((props: Props, ref: any) => {
? claim.permanent_url || claim.canonical_url ? claim.permanent_url || claim.canonical_url
: undefined; : undefined;
const repostedContentUri = claim && (claim.reposted_claim ? claim.reposted_claim.permanent_url : claim.permanent_url); 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 ) // Get channel title ( use name as fallback )
let channelTitle = null; let channelTitle = null;
@ -227,10 +228,9 @@ const ClaimPreview = forwardRef<any, {}>((props: Props, ref: any) => {
} }
} }
// Aria-label value for claim preview const ariaLabelData = isChannelUri ? title : formatClaimPreviewTitle(title, channelTitle, date, mediaDuration);
let 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(); let navigateSearch = new URLSearchParams();
if (listId) { if (listId) {
navigateSearch.set(COLLECTIONS_CONSTS.COLLECTION_ID, listId); navigateSearch.set(COLLECTIONS_CONSTS.COLLECTION_ID, listId);
@ -273,12 +273,19 @@ const ClaimPreview = forwardRef<any, {}>((props: Props, ref: any) => {
shouldHide = true; shouldHide = true;
} }
if (!shouldHide && isPublishSuggestion) {
shouldHide = true;
}
if (!shouldHide && customShouldHide && claim) { if (!shouldHide && customShouldHide && claim) {
if (customShouldHide(claim)) { if (customShouldHide(claim)) {
shouldHide = true; shouldHide = true;
} }
} }
// **************************************************************************
// **************************************************************************
// Weird placement warning // Weird placement warning
// Make sure this happens after we figure out if this claim needs to be hidden // Make sure this happens after we figure out if this claim needs to be hidden
const thumbnailUrl = useGetThumbnail(uri, claim, streamingUrl, getFile, shouldHide); const thumbnailUrl = useGetThumbnail(uri, claim, streamingUrl, getFile, shouldHide);
@ -307,6 +314,9 @@ const ClaimPreview = forwardRef<any, {}>((props: Props, ref: any) => {
} }
}, [isValid, uri, isResolvingUri, shouldFetch, resolveUri]); }, [isValid, uri, isResolvingUri, shouldFetch, resolveUri]);
// **************************************************************************
// **************************************************************************
if ((shouldHide && !showNullPlaceholder) || (isLivestream && !ENABLE_NO_SOURCE_CLAIMS)) { if ((shouldHide && !showNullPlaceholder) || (isLivestream && !ENABLE_NO_SOURCE_CLAIMS)) {
return null; return null;
} }
@ -340,8 +350,9 @@ const ClaimPreview = forwardRef<any, {}>((props: Props, ref: any) => {
</React.Suspense> </React.Suspense>
); );
} }
if (placeholder === 'publish' && !claim && uri.startsWith('lbry://@')) {
return null; if (isPublishSuggestion) {
return null; // Ignore 'showNullPlaceholder'
} }
let liveProperty = null; let liveProperty = null;