From c73ea0094179dfe3a2e5385ea03d771367e02d97 Mon Sep 17 00:00:00 2001 From: Thomas Zarebczan Date: Tue, 11 Jun 2019 12:22:44 -0400 Subject: [PATCH] fix: controlling and channel claim count meta Controlling means controlling claims, not channels. Added so we only return claims with valid signatures (safer for now, can add options to show invalid later). Also, the claim count in channel is in the signed channel meta object, not the high level one. --- dist/bundle.es.js | 26 +++++++++++++------------- dist/flow-typed/Claim.js | 4 ++-- src/redux/actions/claims.js | 6 ++++-- 3 files changed, 19 insertions(+), 17 deletions(-) diff --git a/dist/bundle.es.js b/dist/bundle.es.js index 87cf4e4..536e4f0 100644 --- a/dist/bundle.es.js +++ b/dist/bundle.es.js @@ -1997,7 +1997,7 @@ function doResolveUris(uris, returnCachedClaims = false) { result.stream = uriResolveInfo; if (uriResolveInfo.signing_channel) { result.channel = uriResolveInfo.signing_channel; - result.claimsInChannel = uriResolveInfo.signing_channel.meta.claims_in_channel; + result.claimsInChannel = uriResolveInfo.signing_channel.meta && uriResolveInfo.signing_channel.meta.claims_in_channel || 0; } } @@ -2117,7 +2117,12 @@ function doFetchClaimsByChannel(uri, page = 1) { data: { uri, page } }); - lbryProxy.claim_search({ channel: uri, is_controlling: true, page: page || 1, order_by: ['release_time'] }).then(result => { + lbryProxy.claim_search({ + channel: uri, + valid_channel_signatures: true, + page: page || 1, + order_by: ['release_time'] + }).then(result => { const { items: claimsInChannel, page: returnedPage } = result; dispatch({ @@ -2738,20 +2743,15 @@ reducers[RESOLVE_URIS_COMPLETED] = (state, action) => { // $FlowFixMe Object.entries(resolveInfo).forEach(([uri, { channel, stream }]) => { - if (stream && !channel) { + if (stream) { byId[stream.claim_id] = stream; byUri[uri] = stream.claim_id; - } else if (stream && channel) { - byId[stream.claim_id] = stream; - byUri[uri] = stream.claim_id; - + } + if (channel) { byId[channel.claim_id] = channel; - const channelUri = channel.permanent_url; - byUri[channelUri] = channel.claim_id; - } else if (!stream && channel) { - byId[channel.claim_id] = channel; - byUri[uri] = channel.claim_id; - } else { + byUri[stream ? channel.permanent_url : uri] = channel.claim_id; + } + if (!stream && !channel) { byUri[uri] = null; } }); diff --git a/dist/flow-typed/Claim.js b/dist/flow-typed/Claim.js index e8744f5..f18b128 100644 --- a/dist/flow-typed/Claim.js +++ b/dist/flow-typed/Claim.js @@ -4,13 +4,13 @@ declare type Claim = StreamClaim | ChannelClaim; declare type ChannelClaim = GenericClaim & { is_channel_signature_valid?: boolean, // we may have signed channels in the future, fixes some flow issues for now. - signing_channel?: ChannelMetadata, + signing_channel?: ChannelClaim, value: ChannelMetadata, }; declare type StreamClaim = GenericClaim & { is_channel_signature_valid?: boolean, - signing_channel?: ChannelMetadata, + signing_channel?: ChannelClaim, value: StreamMetadata, }; diff --git a/src/redux/actions/claims.js b/src/redux/actions/claims.js index 3cbffcd..5248309 100644 --- a/src/redux/actions/claims.js +++ b/src/redux/actions/claims.js @@ -64,7 +64,9 @@ export function doResolveUris(uris: Array, returnCachedClaims: boolean = if (uriResolveInfo.signing_channel) { result.channel = uriResolveInfo.signing_channel; result.claimsInChannel = - (uriResolveInfo.meta && uriResolveInfo.meta.claims_in_channel) || 0; + (uriResolveInfo.signing_channel.meta && + uriResolveInfo.signing_channel.meta.claims_in_channel) || + 0; } } @@ -198,7 +200,7 @@ export function doFetchClaimsByChannel(uri: string, page: number = 1) { Lbry.claim_search({ channel: uri, - is_controlling: true, + valid_channel_signatures: true, page: page || 1, order_by: ['release_time'], }).then((result: ClaimSearchResponse) => { -- 2.45.2