Compare commits

...

1 commit

Author SHA1 Message Date
infinite-persistence
df37875e91 Fix inability to unblock an abandoned claim
The recent change to parse the channel from a Repost using a `claim` ended up breaking the case for abandoned claims, which `claim` will be `null`.

Fix by looking at `claim` first (faster), and falling back to the `parseURI` method if it remains inconclusive.
2022-01-25 18:18:32 -05:00
2 changed files with 25 additions and 1 deletions

View file

@ -6,6 +6,7 @@ import { isEmpty } from 'util/object';
import classnames from 'classnames';
import { isURIValid } from 'util/lbryURI';
import * as COLLECTIONS_CONSTS from 'constants/collections';
import { isChannelClaim } from 'util/claim';
import { formatLbryUrlForWeb } from 'util/url';
import { formatClaimPreviewTitle } from 'util/formatAriaLabel';
import FileThumbnail from 'component/fileThumbnail';
@ -170,7 +171,7 @@ const ClaimPreview = forwardRef<any, {}>((props: Props, ref: any) => {
claim.value.stream_type &&
// $FlowFixMe
(claim.value.stream_type === 'audio' || claim.value.stream_type === 'video');
const isChannelUri = claim ? claim.value_type === 'channel' : false;
const isChannelUri = isChannelClaim(claim, uri);
const signingChannel = claim && claim.signing_channel;
const repostedChannelUri =
claim && claim.repost_channel_url && claim.value_type === 'channel'

View file

@ -1,5 +1,6 @@
// @flow
import { MATURE_TAGS } from 'constants/tags';
import { parseURI } from 'util/lbryURI';
const matureTagMap = MATURE_TAGS.reduce((acc, tag) => ({ ...acc, [tag]: true }), {});
@ -66,6 +67,28 @@ export function filterClaims(claims: Array<Claim>, query: ?string): Array<Claim>
return claims;
}
/**
* Determines if the claim is a channel.
*
* @param claim
* @param uri An abandoned claim will be null, so provide the `uri` as a fallback to parse.
*/
export function isChannelClaim(claim: ?Claim, uri?: string) {
// 1. parseURI can't resolve a repost's channel, so a `claim` will be needed.
// 2. parseURI is still needed to cover the case of abandoned claims.
if (claim) {
return claim.value_type === 'channel';
} else if (uri) {
try {
return Boolean(parseURI(uri).isChannel);
} catch (err) {
return false;
}
} else {
return false;
}
}
export function getChannelIdFromClaim(claim: ?Claim) {
if (claim) {
if (claim.value_type === 'channel') {