From 32a671313573004a298b2663e8b474341ea648b3 Mon Sep 17 00:00:00 2001 From: Franco Montenegro Date: Thu, 4 Aug 2022 22:12:36 -0300 Subject: [PATCH] Properly handle blacklisted claims. --- flow-typed/Claim.js | 37 +++++++++++++++++++++++ ui/page/show/index.js | 4 +-- ui/page/show/view.jsx | 58 +++++++++++++----------------------- ui/redux/actions/claims.js | 2 +- ui/redux/reducers/claims.js | 14 +++++---- ui/redux/selectors/claims.js | 33 ++++++++++++++++++++ 6 files changed, 103 insertions(+), 45 deletions(-) diff --git a/flow-typed/Claim.js b/flow-typed/Claim.js index e03eeae81..4c3a63150 100644 --- a/flow-typed/Claim.js +++ b/flow-typed/Claim.js @@ -145,12 +145,49 @@ declare type PurchaseReceipt = { type: 'purchase', }; +declare type ClaimErrorCensor = { + address: string, + amount: string, + canonical_url: string, + claim_id: string, + claim_op: string, + confirmations: number, + has_signing_key: boolean, + height: number, + meta: { + activation_height: number, + claims_in_channel: number, + creation_height: number, + creation_timestamp: number, + effective_amount: string, + expiration_height: number, + is_controlling: boolean, + reposted: number, + support_amount: string, + take_over_height: number, + }, + name: string, + normalized_name: string, + nout: number, + permanent_url: string, + short_url: string, + timestamp: number, + txid: string, + type: string, + value: { + public_key: string, + public_key_id: string, + }, + value_type: string, +} + declare type ClaimActionResolveInfo = { [string]: { stream: ?StreamClaim, channel: ?ChannelClaim, claimsInChannel: ?number, collection: ?CollectionClaim, + errorCensor: ?ClaimErrorCensor, }, } diff --git a/ui/page/show/index.js b/ui/page/show/index.js index 974af2a7b..c47087a37 100644 --- a/ui/page/show/index.js +++ b/ui/page/show/index.js @@ -10,6 +10,7 @@ import { selectTitleForUri, selectClaimIsMine, makeSelectClaimIsPending, + makeSelectIsBlacklisted, } from 'redux/selectors/claims'; import { makeSelectCollectionForId, @@ -23,7 +24,6 @@ import { normalizeURI } from 'util/lbryURI'; import * as COLLECTIONS_CONSTS from 'constants/collections'; import { push } from 'connected-react-router'; import { makeSelectChannelInSubscriptions } from 'redux/selectors/subscriptions'; -import { selectBlackListedOutpoints } from 'lbryinc'; import ShowPage from './view'; const select = (state, props) => { @@ -72,7 +72,6 @@ const select = (state, props) => { uri, claim, isResolvingUri: selectIsUriResolving(state, uri), - blackListedOutpoints: selectBlackListedOutpoints(state), totalPages: makeSelectTotalPagesForChannel(uri, PAGE_SIZE)(state), isSubscribed: makeSelectChannelInSubscriptions(uri)(state), title: selectTitleForUri(state, uri), @@ -82,6 +81,7 @@ const select = (state, props) => { collectionId: collectionId, collectionUrls: makeSelectUrlsForCollectionId(collectionId)(state), isResolvingCollection: makeSelectIsResolvingCollectionForId(collectionId)(state), + isBlacklisted: makeSelectIsBlacklisted(uri)(state), }; }; diff --git a/ui/page/show/view.jsx b/ui/page/show/view.jsx index 08342a665..44a53658b 100644 --- a/ui/page/show/view.jsx +++ b/ui/page/show/view.jsx @@ -22,10 +22,6 @@ type Props = { uri: string, claim: StreamClaim, location: UrlLocation, - blackListedOutpoints: Array<{ - txid: string, - nout: number, - }>, title: string, claimIsMine: boolean, claimIsPending: boolean, @@ -35,6 +31,7 @@ type Props = { collectionUrls: Array, isResolvingCollection: boolean, fetchCollectionItems: (string) => void, + isBlacklisted: boolean, }; function ShowPage(props: Props) { @@ -43,7 +40,6 @@ function ShowPage(props: Props) { resolveUri, uri, claim, - blackListedOutpoints, location, claimIsMine, isSubscribed, @@ -54,11 +50,11 @@ function ShowPage(props: Props) { collection, collectionUrls, isResolvingCollection, + isBlacklisted, } = props; const { search } = location; - const signingChannel = claim && claim.signing_channel; const canonicalUrl = claim && claim.canonical_url; const claimExists = claim !== null && claim !== undefined; const haventFetchedYet = claim === undefined; @@ -103,7 +99,7 @@ function ShowPage(props: Props) { } let innerContent = ''; - if (!claim || (claim && !claim.name)) { + if ((!claim || (claim && !claim.name)) && !isBlacklisted) { innerContent = ( {(claim === undefined || @@ -142,38 +138,26 @@ function ShowPage(props: Props) { {!isResolvingUri && isSubscribed && claim === null && } ); - } else if (claim.name.length && claim.name[0] === '@') { + } else if (claim && claim.name.length && claim.name[0] === '@') { innerContent = ; + } else if (isBlacklisted && !claimIsMine) { + innerContent = ( + + +