fix: more 38 changes
Fixed resolving by signed_channel, order for claim search and timestamp to use release date / creation date (to match sorting). We'll probably want to show updated_date somewhere in advanced section eventually. Needs some flow love
This commit is contained in:
parent
5c8d3b4143
commit
b419a1bfa9
9 changed files with 114 additions and 123 deletions
48
dist/bundle.es.js
vendored
48
dist/bundle.es.js
vendored
|
@ -1269,7 +1269,7 @@ const makeSelectMetadataItemForUri = (uri, key) => reselect.createSelector(makeS
|
||||||
const makeSelectTitleForUri = uri => reselect.createSelector(makeSelectMetadataForUri(uri), metadata => metadata && metadata.title);
|
const makeSelectTitleForUri = uri => reselect.createSelector(makeSelectMetadataForUri(uri), metadata => metadata && metadata.title);
|
||||||
|
|
||||||
const makeSelectDateForUri = uri => reselect.createSelector(makeSelectClaimForUri(uri), claim => {
|
const makeSelectDateForUri = uri => reselect.createSelector(makeSelectClaimForUri(uri), claim => {
|
||||||
const timestamp = claim && claim.timestamp ? claim.timestamp * 1000 : undefined;
|
const timestamp = claim && claim.value && (claim.value.release_time ? claim.value.release_time * 1000 : claim.value.meta.creation_timestamp * 1000);
|
||||||
if (!timestamp) {
|
if (!timestamp) {
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
@ -1968,9 +1968,9 @@ function doResolveUris(uris, returnCachedClaims = false) {
|
||||||
lbryProxy.resolve({ urls: urisToResolve }).then(result => {
|
lbryProxy.resolve({ urls: urisToResolve }).then(result => {
|
||||||
Object.entries(result).forEach(([uri, uriResolveInfo]) => {
|
Object.entries(result).forEach(([uri, uriResolveInfo]) => {
|
||||||
const fallbackResolveInfo = {
|
const fallbackResolveInfo = {
|
||||||
claim: null,
|
stream: null,
|
||||||
claimsInChannel: null,
|
claimsInChannel: null,
|
||||||
certificate: null
|
channel: null
|
||||||
};
|
};
|
||||||
|
|
||||||
// Flow has terrible Object.entries support
|
// Flow has terrible Object.entries support
|
||||||
|
@ -1981,11 +1981,15 @@ function doResolveUris(uris, returnCachedClaims = false) {
|
||||||
} else {
|
} else {
|
||||||
let result = {};
|
let result = {};
|
||||||
if (uriResolveInfo.value_type === 'channel') {
|
if (uriResolveInfo.value_type === 'channel') {
|
||||||
result.certificate = uriResolveInfo;
|
result.channel = uriResolveInfo;
|
||||||
// $FlowFixMe
|
// $FlowFixMe
|
||||||
result.claimsInChannel = uriResolveInfo.meta.claims_in_channel;
|
result.claimsInChannel = uriResolveInfo.meta.claims_in_channel;
|
||||||
} else {
|
} else {
|
||||||
result.claim = uriResolveInfo;
|
result.stream = uriResolveInfo;
|
||||||
|
if (uriResolveInfo.signing_channel) {
|
||||||
|
result.channel = uriResolveInfo.signing_channel;
|
||||||
|
result.claimsInChannel = uriResolveInfo.signing_channel.meta.claims_in_channel;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// $FlowFixMe
|
// $FlowFixMe
|
||||||
|
@ -2104,7 +2108,7 @@ function doFetchClaimsByChannel(uri, page = 1) {
|
||||||
data: { uri, page }
|
data: { uri, page }
|
||||||
});
|
});
|
||||||
|
|
||||||
lbryProxy.claim_search({ channel: uri, controlling: true, page: page || 1 }).then(result => {
|
lbryProxy.claim_search({ channel: uri, is_controlling: true, page: page || 1, order_by: ['release_time'] }).then(result => {
|
||||||
const { items: claimsInChannel, page: returnedPage } = result;
|
const { items: claimsInChannel, page: returnedPage } = result;
|
||||||
|
|
||||||
dispatch({
|
dispatch({
|
||||||
|
@ -2708,34 +2712,36 @@ const defaultState = {
|
||||||
};
|
};
|
||||||
|
|
||||||
reducers[RESOLVE_URIS_COMPLETED] = (state, action) => {
|
reducers[RESOLVE_URIS_COMPLETED] = (state, action) => {
|
||||||
const { resolveInfo } = action.data;
|
const {
|
||||||
|
resolveInfo
|
||||||
|
} = action.data;
|
||||||
const byUri = Object.assign({}, state.claimsByUri);
|
const byUri = Object.assign({}, state.claimsByUri);
|
||||||
const byId = Object.assign({}, state.byId);
|
const byId = Object.assign({}, state.byId);
|
||||||
const channelClaimCounts = Object.assign({}, state.channelClaimCounts);
|
const channelClaimCounts = Object.assign({}, state.channelClaimCounts);
|
||||||
|
|
||||||
Object.entries(resolveInfo).forEach(([uri, resolveResponse]) => {
|
Object.entries(resolveInfo).forEach(([uri, resolveResponse]) => {
|
||||||
// $FlowFixMe
|
// $FlowFixMe
|
||||||
if (resolveResponse.certificate && !Number.isNaN(resolveResponse.claimsInChannel)) {
|
if (resolveResponse.claimsInChannel) {
|
||||||
// $FlowFixMe
|
// $FlowFixMe
|
||||||
channelClaimCounts[uri] = resolveResponse.claimsInChannel;
|
channelClaimCounts[uri] = resolveResponse.claimsInChannel;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// $FlowFixMe
|
// $FlowFixMe
|
||||||
Object.entries(resolveInfo).forEach(([uri, { certificate, claim }]) => {
|
Object.entries(resolveInfo).forEach(([uri, { channel, stream }]) => {
|
||||||
if (claim && !certificate) {
|
if (stream && !channel) {
|
||||||
byId[claim.claim_id] = claim;
|
byId[stream.claim_id] = stream;
|
||||||
byUri[uri] = claim.claim_id;
|
byUri[uri] = stream.claim_id;
|
||||||
} else if (claim && certificate) {
|
} else if (stream && channel) {
|
||||||
byId[claim.claim_id] = claim;
|
byId[stream.claim_id] = stream;
|
||||||
byUri[uri] = claim.claim_id;
|
byUri[uri] = stream.claim_id;
|
||||||
|
|
||||||
byId[certificate.claim_id] = certificate;
|
byId[channel.claim_id] = channel;
|
||||||
const channelUri = `lbry://${certificate.name}#${certificate.claim_id}`;
|
const channelUri = channel.permanent_url;
|
||||||
byUri[channelUri] = certificate.claim_id;
|
byUri[channelUri] = channel.claim_id;
|
||||||
} else if (!claim && certificate) {
|
} else if (!stream && channel) {
|
||||||
byId[certificate.claim_id] = certificate;
|
byId[channel.claim_id] = channel;
|
||||||
byUri[uri] = certificate.claim_id;
|
byUri[uri] = channel.claim_id;
|
||||||
} else {
|
} else {
|
||||||
byUri[uri] = null;
|
byUri[uri] = null;
|
||||||
}
|
}
|
||||||
|
|
36
dist/flow-typed/Claim.js
vendored
36
dist/flow-typed/Claim.js
vendored
|
@ -1,51 +1,41 @@
|
||||||
// @flow
|
// @flow
|
||||||
|
|
||||||
declare type ClaimWithPossibleCertificate = {
|
declare type Claim = StreamClaim | ChannelClaim;
|
||||||
certificate?: ChannelClaim,
|
|
||||||
claim: StreamClaim,
|
|
||||||
};
|
|
||||||
|
|
||||||
declare type ChannelClaim = GenericClaim & {
|
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,
|
||||||
value: ChannelMetadata,
|
value: ChannelMetadata,
|
||||||
};
|
};
|
||||||
|
|
||||||
declare type StreamClaim = GenericClaim & {
|
declare type StreamClaim = GenericClaim & {
|
||||||
is_channel_signature_valid?: boolean,
|
is_channel_signature_valid?: boolean,
|
||||||
signing_channel?: {
|
signing_channel?: ChannelMetadata,
|
||||||
claim_id: string,
|
|
||||||
name: string,
|
|
||||||
value: {
|
|
||||||
public_key: string,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
value: StreamMetadata,
|
value: StreamMetadata,
|
||||||
};
|
};
|
||||||
|
|
||||||
declare type GenericClaim = {
|
declare type GenericClaim = {
|
||||||
address: string, // address associated with tx
|
address: string, // address associated with tx
|
||||||
amount: number, // bid amount at time of tx
|
amount: string, // bid amount at time of tx
|
||||||
|
canonical_url: string, // URL with short id, includes channel with short id
|
||||||
claim_id: string, // unique claim identifier
|
claim_id: string, // unique claim identifier
|
||||||
claim_sequence: number,
|
claim_sequence: number, // not being used currently
|
||||||
claim_op: 'create' | 'update',
|
claim_op: 'create' | 'update',
|
||||||
confirmations: number, // This isn't the most stable atm: https://github.com/lbryio/lbry/issues/2000
|
confirmations: number,
|
||||||
decoded_claim: boolean, // claim made in accordance with sdk protobuf types
|
decoded_claim: boolean, // Not available currently https://github.com/lbryio/lbry/issues/2044
|
||||||
effective_amount: number, // bid amount + supports
|
timestamp?: number, // date of last transaction
|
||||||
timestamp?: number, // date of transaction
|
|
||||||
has_signature: boolean,
|
|
||||||
height: number, // block height the tx was confirmed
|
height: number, // block height the tx was confirmed
|
||||||
hex: string, // `value` hex encoded
|
|
||||||
name: string,
|
name: string,
|
||||||
channel_name?: string,
|
|
||||||
normalized_name: string, // `name` normalized via unicode NFD spec,
|
normalized_name: string, // `name` normalized via unicode NFD spec,
|
||||||
nout: number, // index number for an output of a tx
|
nout: number, // index number for an output of a tx
|
||||||
permanent_url: string, // name + claim_id
|
permanent_url: string, // name + claim_id
|
||||||
supports: Array<{}>, // TODO: add support type once we start using it
|
short_url: string, // permanent_url with short id, no channel
|
||||||
txid: string, // unique tx id
|
txid: string, // unique tx id
|
||||||
type: 'claim' | 'update' | 'support',
|
type: 'claim' | 'update' | 'support',
|
||||||
valid_at_height?: number, // BUG: this should always exist https://github.com/lbryio/lbry/issues/1728
|
|
||||||
value_type: 'stream' | 'channel',
|
value_type: 'stream' | 'channel',
|
||||||
meta: {
|
meta: {
|
||||||
activation_height: number,
|
activation_height: number,
|
||||||
|
claims_in_channel?: number,
|
||||||
creation_height: number,
|
creation_height: number,
|
||||||
creation_timestamp: number,
|
creation_timestamp: number,
|
||||||
effective_amount: string,
|
effective_amount: string,
|
||||||
|
@ -56,7 +46,6 @@ declare type GenericClaim = {
|
||||||
trending_group: number,
|
trending_group: number,
|
||||||
trending_local: number,
|
trending_local: number,
|
||||||
trending_mixed: number,
|
trending_mixed: number,
|
||||||
claims_in_channel?: number,
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -73,6 +62,7 @@ declare type GenericMetadata = {
|
||||||
|
|
||||||
declare type ChannelMetadata = GenericMetadata & {
|
declare type ChannelMetadata = GenericMetadata & {
|
||||||
public_key: string,
|
public_key: string,
|
||||||
|
public_key_id: string,
|
||||||
cover_url?: string,
|
cover_url?: string,
|
||||||
email?: string,
|
email?: string,
|
||||||
website_url?: string,
|
website_url?: string,
|
||||||
|
|
13
dist/flow-typed/Lbry.js
vendored
13
dist/flow-typed/Lbry.js
vendored
|
@ -66,9 +66,7 @@ declare type VersionResponse = {
|
||||||
declare type ResolveResponse = {
|
declare type ResolveResponse = {
|
||||||
// Keys are the url(s) passed to resolve
|
// Keys are the url(s) passed to resolve
|
||||||
[string]:
|
[string]:
|
||||||
| { error: {}, certificate: ChannelClaim, claims_in_channel: number }
|
| Claim
|
||||||
| StreamClaim
|
|
||||||
| ChannelClaim
|
|
||||||
| { error?: {} },
|
| { error?: {} },
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -88,18 +86,19 @@ declare type GenericTxResponse = {
|
||||||
declare type PublishResponse = GenericTxResponse & {
|
declare type PublishResponse = GenericTxResponse & {
|
||||||
// Only first value in outputs is a claim
|
// Only first value in outputs is a claim
|
||||||
// That's the only value we care about
|
// That's the only value we care about
|
||||||
outputs: Array<StreamClaim>,
|
outputs: Array<Claim>,
|
||||||
};
|
};
|
||||||
|
|
||||||
declare type ClaimSearchResponse = {
|
declare type ClaimSearchResponse = {
|
||||||
items: Array<StreamClaim>,
|
items: Array<Claim>,
|
||||||
page: number,
|
page: number,
|
||||||
page_size: number,
|
page_size: number,
|
||||||
page_number: number,
|
total_items: number,
|
||||||
|
total_pages: number,
|
||||||
};
|
};
|
||||||
|
|
||||||
declare type ClaimListResponse = {
|
declare type ClaimListResponse = {
|
||||||
claims: Array<ChannelClaim | StreamClaim>,
|
claims: Array<ChannelClaim | Claim>,
|
||||||
};
|
};
|
||||||
|
|
||||||
declare type ChannelCreateResponse = GenericTxResponse & {
|
declare type ChannelCreateResponse = GenericTxResponse & {
|
||||||
|
|
36
flow-typed/Claim.js
vendored
36
flow-typed/Claim.js
vendored
|
@ -1,51 +1,41 @@
|
||||||
// @flow
|
// @flow
|
||||||
|
|
||||||
declare type ClaimWithPossibleCertificate = {
|
declare type Claim = StreamClaim | ChannelClaim;
|
||||||
certificate?: ChannelClaim,
|
|
||||||
claim: StreamClaim,
|
|
||||||
};
|
|
||||||
|
|
||||||
declare type ChannelClaim = GenericClaim & {
|
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,
|
||||||
value: ChannelMetadata,
|
value: ChannelMetadata,
|
||||||
};
|
};
|
||||||
|
|
||||||
declare type StreamClaim = GenericClaim & {
|
declare type StreamClaim = GenericClaim & {
|
||||||
is_channel_signature_valid?: boolean,
|
is_channel_signature_valid?: boolean,
|
||||||
signing_channel?: {
|
signing_channel?: ChannelMetadata,
|
||||||
claim_id: string,
|
|
||||||
name: string,
|
|
||||||
value: {
|
|
||||||
public_key: string,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
value: StreamMetadata,
|
value: StreamMetadata,
|
||||||
};
|
};
|
||||||
|
|
||||||
declare type GenericClaim = {
|
declare type GenericClaim = {
|
||||||
address: string, // address associated with tx
|
address: string, // address associated with tx
|
||||||
amount: number, // bid amount at time of tx
|
amount: string, // bid amount at time of tx
|
||||||
|
canonical_url: string, // URL with short id, includes channel with short id
|
||||||
claim_id: string, // unique claim identifier
|
claim_id: string, // unique claim identifier
|
||||||
claim_sequence: number,
|
claim_sequence: number, // not being used currently
|
||||||
claim_op: 'create' | 'update',
|
claim_op: 'create' | 'update',
|
||||||
confirmations: number, // This isn't the most stable atm: https://github.com/lbryio/lbry/issues/2000
|
confirmations: number,
|
||||||
decoded_claim: boolean, // claim made in accordance with sdk protobuf types
|
decoded_claim: boolean, // Not available currently https://github.com/lbryio/lbry/issues/2044
|
||||||
effective_amount: number, // bid amount + supports
|
timestamp?: number, // date of last transaction
|
||||||
timestamp?: number, // date of transaction
|
|
||||||
has_signature: boolean,
|
|
||||||
height: number, // block height the tx was confirmed
|
height: number, // block height the tx was confirmed
|
||||||
hex: string, // `value` hex encoded
|
|
||||||
name: string,
|
name: string,
|
||||||
channel_name?: string,
|
|
||||||
normalized_name: string, // `name` normalized via unicode NFD spec,
|
normalized_name: string, // `name` normalized via unicode NFD spec,
|
||||||
nout: number, // index number for an output of a tx
|
nout: number, // index number for an output of a tx
|
||||||
permanent_url: string, // name + claim_id
|
permanent_url: string, // name + claim_id
|
||||||
supports: Array<{}>, // TODO: add support type once we start using it
|
short_url: string, // permanent_url with short id, no channel
|
||||||
txid: string, // unique tx id
|
txid: string, // unique tx id
|
||||||
type: 'claim' | 'update' | 'support',
|
type: 'claim' | 'update' | 'support',
|
||||||
valid_at_height?: number, // BUG: this should always exist https://github.com/lbryio/lbry/issues/1728
|
|
||||||
value_type: 'stream' | 'channel',
|
value_type: 'stream' | 'channel',
|
||||||
meta: {
|
meta: {
|
||||||
activation_height: number,
|
activation_height: number,
|
||||||
|
claims_in_channel?: number,
|
||||||
creation_height: number,
|
creation_height: number,
|
||||||
creation_timestamp: number,
|
creation_timestamp: number,
|
||||||
effective_amount: string,
|
effective_amount: string,
|
||||||
|
@ -56,7 +46,6 @@ declare type GenericClaim = {
|
||||||
trending_group: number,
|
trending_group: number,
|
||||||
trending_local: number,
|
trending_local: number,
|
||||||
trending_mixed: number,
|
trending_mixed: number,
|
||||||
claims_in_channel?: number,
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -73,6 +62,7 @@ declare type GenericMetadata = {
|
||||||
|
|
||||||
declare type ChannelMetadata = GenericMetadata & {
|
declare type ChannelMetadata = GenericMetadata & {
|
||||||
public_key: string,
|
public_key: string,
|
||||||
|
public_key_id: string,
|
||||||
cover_url?: string,
|
cover_url?: string,
|
||||||
email?: string,
|
email?: string,
|
||||||
website_url?: string,
|
website_url?: string,
|
||||||
|
|
13
flow-typed/Lbry.js
vendored
13
flow-typed/Lbry.js
vendored
|
@ -66,9 +66,7 @@ declare type VersionResponse = {
|
||||||
declare type ResolveResponse = {
|
declare type ResolveResponse = {
|
||||||
// Keys are the url(s) passed to resolve
|
// Keys are the url(s) passed to resolve
|
||||||
[string]:
|
[string]:
|
||||||
| { error: {}, certificate: ChannelClaim, claims_in_channel: number }
|
| Claim
|
||||||
| StreamClaim
|
|
||||||
| ChannelClaim
|
|
||||||
| { error?: {} },
|
| { error?: {} },
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -88,18 +86,19 @@ declare type GenericTxResponse = {
|
||||||
declare type PublishResponse = GenericTxResponse & {
|
declare type PublishResponse = GenericTxResponse & {
|
||||||
// Only first value in outputs is a claim
|
// Only first value in outputs is a claim
|
||||||
// That's the only value we care about
|
// That's the only value we care about
|
||||||
outputs: Array<StreamClaim>,
|
outputs: Array<Claim>,
|
||||||
};
|
};
|
||||||
|
|
||||||
declare type ClaimSearchResponse = {
|
declare type ClaimSearchResponse = {
|
||||||
items: Array<StreamClaim>,
|
items: Array<Claim>,
|
||||||
page: number,
|
page: number,
|
||||||
page_size: number,
|
page_size: number,
|
||||||
page_number: number,
|
total_items: number,
|
||||||
|
total_pages: number,
|
||||||
};
|
};
|
||||||
|
|
||||||
declare type ClaimListResponse = {
|
declare type ClaimListResponse = {
|
||||||
claims: Array<ChannelClaim | StreamClaim>,
|
claims: Array<ChannelClaim | Claim>,
|
||||||
};
|
};
|
||||||
|
|
||||||
declare type ChannelCreateResponse = GenericTxResponse & {
|
declare type ChannelCreateResponse = GenericTxResponse & {
|
||||||
|
|
|
@ -34,8 +34,8 @@ export function doResolveUris(uris: Array<string>, returnCachedClaims: boolean =
|
||||||
|
|
||||||
const resolveInfo: {
|
const resolveInfo: {
|
||||||
[string]: {
|
[string]: {
|
||||||
claim: ?StreamClaim,
|
stream: ?StreamClaim,
|
||||||
certificate: ?ChannelClaim,
|
channel: ?ChannelClaim,
|
||||||
claimsInChannel: ?number,
|
claimsInChannel: ?number,
|
||||||
},
|
},
|
||||||
} = {};
|
} = {};
|
||||||
|
@ -43,9 +43,9 @@ export function doResolveUris(uris: Array<string>, returnCachedClaims: boolean =
|
||||||
Lbry.resolve({ urls: urisToResolve }).then((result: ResolveResponse) => {
|
Lbry.resolve({ urls: urisToResolve }).then((result: ResolveResponse) => {
|
||||||
Object.entries(result).forEach(([uri, uriResolveInfo]) => {
|
Object.entries(result).forEach(([uri, uriResolveInfo]) => {
|
||||||
const fallbackResolveInfo = {
|
const fallbackResolveInfo = {
|
||||||
claim: null,
|
stream: null,
|
||||||
claimsInChannel: null,
|
claimsInChannel: null,
|
||||||
certificate: null,
|
channel: null,
|
||||||
};
|
};
|
||||||
|
|
||||||
// Flow has terrible Object.entries support
|
// Flow has terrible Object.entries support
|
||||||
|
@ -55,12 +55,16 @@ export function doResolveUris(uris: Array<string>, returnCachedClaims: boolean =
|
||||||
resolveInfo[uri] = { ...fallbackResolveInfo };
|
resolveInfo[uri] = { ...fallbackResolveInfo };
|
||||||
} else {
|
} else {
|
||||||
let result = {};
|
let result = {};
|
||||||
if (uriResolveInfo.value_type === 'channel') {
|
if (uriResolveInfo.value_type === 'channel' ) {
|
||||||
result.certificate = uriResolveInfo;
|
result.channel = uriResolveInfo;
|
||||||
// $FlowFixMe
|
// $FlowFixMe
|
||||||
result.claimsInChannel = uriResolveInfo.meta.claims_in_channel;
|
result.claimsInChannel = uriResolveInfo.meta.claims_in_channel;
|
||||||
} else {
|
} else {
|
||||||
result.claim = uriResolveInfo;
|
result.stream = uriResolveInfo;
|
||||||
|
if (uriResolveInfo.signing_channel) {
|
||||||
|
result.channel = uriResolveInfo.signing_channel;
|
||||||
|
result.claimsInChannel = uriResolveInfo.signing_channel.meta.claims_in_channel;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// $FlowFixMe
|
// $FlowFixMe
|
||||||
|
@ -103,7 +107,7 @@ export function doAbandonClaim(txid: string, nout: number) {
|
||||||
|
|
||||||
return (dispatch: Dispatch, getState: GetState) => {
|
return (dispatch: Dispatch, getState: GetState) => {
|
||||||
const state = getState();
|
const state = getState();
|
||||||
const myClaims: Array<ChannelClaim | StreamClaim> = selectMyClaimsRaw(state);
|
const myClaims: Array<Claim> = selectMyClaimsRaw(state);
|
||||||
const mySupports: { [string]: Support } = selectSupportsByOutpoint(state);
|
const mySupports: { [string]: Support } = selectSupportsByOutpoint(state);
|
||||||
|
|
||||||
// A user could be trying to abandon a support or one of their claims
|
// A user could be trying to abandon a support or one of their claims
|
||||||
|
@ -191,7 +195,7 @@ export function doFetchClaimsByChannel(uri: string, page: number = 1) {
|
||||||
data: { uri, page },
|
data: { uri, page },
|
||||||
});
|
});
|
||||||
|
|
||||||
Lbry.claim_search({ channel: uri, controlling: true, page: page || 1 }).then(
|
Lbry.claim_search({ channel: uri, is_controlling: true, page: page || 1, order_by: ['release_time'] }).then(
|
||||||
(result: ClaimSearchResponse) => {
|
(result: ClaimSearchResponse) => {
|
||||||
const { items: claimsInChannel, page: returnedPage } = result;
|
const { items: claimsInChannel, page: returnedPage } = result;
|
||||||
|
|
||||||
|
|
|
@ -14,9 +14,9 @@ import { buildURI, parseURI } from 'lbryURI';
|
||||||
type State = {
|
type State = {
|
||||||
channelClaimCounts: { [string]: number },
|
channelClaimCounts: { [string]: number },
|
||||||
claimsByUri: { [string]: string },
|
claimsByUri: { [string]: string },
|
||||||
byId: { [string]: StreamClaim | ChannelClaim },
|
byId: { [string]: Claim },
|
||||||
resolvingUris: Array<string>,
|
resolvingUris: Array<string>,
|
||||||
pendingById: { [string]: StreamClaim | ChannelClaim },
|
pendingById: { [string]: Claim },
|
||||||
myChannelClaims: Set<string>,
|
myChannelClaims: Set<string>,
|
||||||
abandoningById: { [string]: boolean },
|
abandoningById: { [string]: boolean },
|
||||||
fetchingChannelClaims: { [string]: number },
|
fetchingChannelClaims: { [string]: number },
|
||||||
|
@ -46,36 +46,42 @@ const defaultState = {
|
||||||
};
|
};
|
||||||
|
|
||||||
reducers[ACTIONS.RESOLVE_URIS_COMPLETED] = (state: State, action: any): State => {
|
reducers[ACTIONS.RESOLVE_URIS_COMPLETED] = (state: State, action: any): State => {
|
||||||
const { resolveInfo }: { [string]: ClaimWithPossibleCertificate } = action.data;
|
const {
|
||||||
|
resolveInfo,
|
||||||
|
}: {
|
||||||
|
[string]: {
|
||||||
|
stream: ?StreamClaim,
|
||||||
|
channel: ?ChannelClaim,
|
||||||
|
claimsInChannel: ?number,
|
||||||
|
},
|
||||||
|
} = action.data;
|
||||||
const byUri = Object.assign({}, state.claimsByUri);
|
const byUri = Object.assign({}, state.claimsByUri);
|
||||||
const byId = Object.assign({}, state.byId);
|
const byId = Object.assign({}, state.byId);
|
||||||
const channelClaimCounts = Object.assign({}, state.channelClaimCounts);
|
const channelClaimCounts = Object.assign({}, state.channelClaimCounts);
|
||||||
|
|
||||||
Object.entries(resolveInfo).forEach(
|
Object.entries(resolveInfo).forEach(([uri: string, resolveResponse: Claim]) => {
|
||||||
([uri: string, resolveResponse: ClaimWithPossibleCertificate]) => {
|
// $FlowFixMe
|
||||||
|
if (resolveResponse.claimsInChannel) {
|
||||||
// $FlowFixMe
|
// $FlowFixMe
|
||||||
if (resolveResponse.certificate && !Number.isNaN(resolveResponse.claimsInChannel)) {
|
channelClaimCounts[uri] = resolveResponse.claimsInChannel;
|
||||||
// $FlowFixMe
|
|
||||||
channelClaimCounts[uri] = resolveResponse.claimsInChannel;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
);
|
});
|
||||||
|
|
||||||
// $FlowFixMe
|
// $FlowFixMe
|
||||||
Object.entries(resolveInfo).forEach(([uri, { certificate, claim }]) => {
|
Object.entries(resolveInfo).forEach(([uri, { channel, stream }]) => {
|
||||||
if (claim && !certificate) {
|
if (stream && !channel) {
|
||||||
byId[claim.claim_id] = claim;
|
byId[stream.claim_id] = stream;
|
||||||
byUri[uri] = claim.claim_id;
|
byUri[uri] = stream.claim_id;
|
||||||
} else if (claim && certificate) {
|
} else if (stream && channel) {
|
||||||
byId[claim.claim_id] = claim;
|
byId[stream.claim_id] = stream;
|
||||||
byUri[uri] = claim.claim_id;
|
byUri[uri] = stream.claim_id;
|
||||||
|
|
||||||
byId[certificate.claim_id] = certificate;
|
byId[channel.claim_id] = channel;
|
||||||
const channelUri = `lbry://${certificate.name}#${certificate.claim_id}`;
|
const channelUri = channel.permanent_url;
|
||||||
byUri[channelUri] = certificate.claim_id;
|
byUri[channelUri] = channel.claim_id;
|
||||||
} else if (!claim && certificate) {
|
} else if (!stream && channel) {
|
||||||
byId[certificate.claim_id] = certificate;
|
byId[channel.claim_id] = channel;
|
||||||
byUri[uri] = certificate.claim_id;
|
byUri[uri] = channel.claim_id;
|
||||||
} else {
|
} else {
|
||||||
byUri[uri] = null;
|
byUri[uri] = null;
|
||||||
}
|
}
|
||||||
|
@ -95,15 +101,12 @@ reducers[ACTIONS.FETCH_CLAIM_LIST_MINE_STARTED] = (state: State): State =>
|
||||||
});
|
});
|
||||||
|
|
||||||
reducers[ACTIONS.FETCH_CLAIM_LIST_MINE_COMPLETED] = (state: State, action: any): State => {
|
reducers[ACTIONS.FETCH_CLAIM_LIST_MINE_COMPLETED] = (state: State, action: any): State => {
|
||||||
const { claims }: { claims: Array<StreamClaim | ChannelClaim> } = action.data;
|
const { claims }: { claims: Array<Claim> } = action.data;
|
||||||
const byId = Object.assign({}, state.byId);
|
const byId = Object.assign({}, state.byId);
|
||||||
const byUri = Object.assign({}, state.claimsByUri);
|
const byUri = Object.assign({}, state.claimsByUri);
|
||||||
const pendingById: { [string]: StreamClaim | ChannelClaim } = Object.assign(
|
const pendingById: { [string]: Claim } = Object.assign({}, state.pendingById);
|
||||||
{},
|
|
||||||
state.pendingById
|
|
||||||
);
|
|
||||||
|
|
||||||
claims.forEach((claim: StreamClaim | ChannelClaim) => {
|
claims.forEach((claim: Claim) => {
|
||||||
const uri = buildURI({ claimName: claim.name, claimId: claim.claim_id });
|
const uri = buildURI({ claimName: claim.name, claimId: claim.claim_id });
|
||||||
|
|
||||||
if (claim.type && claim.type.match(/claim|update/)) {
|
if (claim.type && claim.type.match(/claim|update/)) {
|
||||||
|
|
|
@ -190,7 +190,7 @@ export const makeSelectDateForUri = (uri: string) =>
|
||||||
createSelector(
|
createSelector(
|
||||||
makeSelectClaimForUri(uri),
|
makeSelectClaimForUri(uri),
|
||||||
claim => {
|
claim => {
|
||||||
const timestamp = claim && claim.timestamp ? claim.timestamp * 1000 : undefined;
|
const timestamp = claim && claim.value && (claim.value.release_time ? claim.value.release_time * 1000 : claim.value.meta.creation_timestamp * 1000);
|
||||||
if (!timestamp) {
|
if (!timestamp) {
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
@ -368,7 +368,7 @@ export const makeSelectClaimIsNsfw = (uri: string): boolean =>
|
||||||
// Or possibly come from users settings of what tags they want to hide
|
// Or possibly come from users settings of what tags they want to hide
|
||||||
// For now, there is just a hard coded list of tags inside `isClaimNsfw`
|
// For now, there is just a hard coded list of tags inside `isClaimNsfw`
|
||||||
// selectNaughtyTags(),
|
// selectNaughtyTags(),
|
||||||
(claim: StreamClaim) => {
|
(claim: Claim) => {
|
||||||
if (!claim) {
|
if (!claim) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -418,7 +418,7 @@ export const makeSelectFirstRecommendedFileForUri = (uri: string) =>
|
||||||
export const makeSelectChannelForClaimUri = (uri: string, includePrefix: boolean = false) =>
|
export const makeSelectChannelForClaimUri = (uri: string, includePrefix: boolean = false) =>
|
||||||
createSelector(
|
createSelector(
|
||||||
makeSelectClaimForUri(uri),
|
makeSelectClaimForUri(uri),
|
||||||
(claim: ?StreamClaim) => {
|
(claim: ?Claim) => {
|
||||||
if (!claim || !claim.signing_channel) {
|
if (!claim || !claim.signing_channel) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@ const naughtyTags = ['porn', 'nsfw', 'mature', 'xxx'].reduce(
|
||||||
{}
|
{}
|
||||||
);
|
);
|
||||||
|
|
||||||
export const isClaimNsfw = (claim: StreamClaim): boolean => {
|
export const isClaimNsfw = (claim: Claim): boolean => {
|
||||||
if (!claim) {
|
if (!claim) {
|
||||||
throw new Error('No claim passed to isClaimNsfw()');
|
throw new Error('No claim passed to isClaimNsfw()');
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue