From 034838a23ccac0f40c450e11dfc31e7410d24806 Mon Sep 17 00:00:00 2001 From: zeppi Date: Thu, 3 Dec 2020 19:25:41 -0500 Subject: [PATCH 1/5] support search finding pending claims --- dist/bundle.es.js | 17 +++++++++++++++++ src/index.js | 2 ++ src/redux/actions/claims.js | 6 ++++++ src/redux/selectors/claims.js | 14 ++++++++++++++ 4 files changed, 39 insertions(+) diff --git a/dist/bundle.es.js b/dist/bundle.es.js index 5e682c7..6e19967 100644 --- a/dist/bundle.es.js +++ b/dist/bundle.es.js @@ -2457,6 +2457,15 @@ const selectPlayingUri = reselect.createSelector(selectState$1, state => state.p const selectChannelClaimCounts = reselect.createSelector(selectState$1, state => state.channelClaimCounts || {}); +const makeSelectPendingClaimUrlForName = name => reselect.createSelector(selectPendingIds, selectClaimsById, (pending, claims) => { + const pendingClaims = pending.map(id => claims[id]); + const matchingClaim = pendingClaims.find(claim => { + const { streamName } = parseURI(claim.permanent_url); + return name === streamName; + }); + return matchingClaim && matchingClaim.permanent_url; +}); + const makeSelectTotalItemsForChannel = uri => reselect.createSelector(selectChannelClaimCounts, byUri => byUri && byUri[uri]); const makeSelectTotalPagesForChannel = (uri, pageSize = 10) => reselect.createSelector(selectChannelClaimCounts, byUri => byUri && byUri[uri] && Math.ceil(byUri[uri] / pageSize)); @@ -3684,6 +3693,12 @@ function doRepost(options) { repostClaim } }); + dispatch({ + type: UPDATE_PENDING_CLAIMS, + data: { + claims: [repostClaim] + } + }); dispatch(doFetchClaimListMine(1, 10)); resolve(repostClaim); @@ -6222,6 +6237,7 @@ exports.makeSelectNsfwCountForChannel = makeSelectNsfwCountForChannel; exports.makeSelectNsfwCountFromUris = makeSelectNsfwCountFromUris; exports.makeSelectOmittedCountForChannel = makeSelectOmittedCountForChannel; exports.makeSelectPendingAmountByUri = makeSelectPendingAmountByUri; +exports.makeSelectPendingClaimUrlForName = makeSelectPendingClaimUrlForName; exports.makeSelectPermanentUrlForUri = makeSelectPermanentUrlForUri; exports.makeSelectPublishFormValue = makeSelectPublishFormValue; exports.makeSelectReflectingClaimForUri = makeSelectReflectingClaimForUri; @@ -6313,6 +6329,7 @@ exports.selectMyClaimsWithoutChannels = selectMyClaimsWithoutChannels; exports.selectMyPurchases = selectMyPurchases; exports.selectMyPurchasesCount = selectMyPurchasesCount; exports.selectMyStreamUrlsCount = selectMyStreamUrlsCount; +exports.selectPendingIds = selectPendingIds; exports.selectPendingSupportTransactions = selectPendingSupportTransactions; exports.selectPlayingUri = selectPlayingUri; exports.selectPublishFormValues = selectPublishFormValues; diff --git a/src/index.js b/src/index.js index 67410f2..95254e4 100644 --- a/src/index.js +++ b/src/index.js @@ -161,6 +161,7 @@ export { makeSelectTagInClaimOrChannelForUri, makeSelectContentTypeForUri, makeSelectIsUriResolving, + makeSelectPendingClaimUrlForName, makeSelectTotalItemsForChannel, makeSelectTotalPagesForChannel, makeSelectNsfwCountFromUris, @@ -181,6 +182,7 @@ export { makeSelectClaimWasPurchased, makeSelectAbandoningClaimById, makeSelectIsAbandoningClaimForUri, + selectPendingIds, selectReflectingById, selectClaimsById, selectClaimsByUri, diff --git a/src/redux/actions/claims.js b/src/redux/actions/claims.js index 2504336..8fe9551 100644 --- a/src/redux/actions/claims.js +++ b/src/redux/actions/claims.js @@ -611,6 +611,12 @@ export function doRepost(options: StreamRepostOptions) { repostClaim, }, }); + dispatch({ + type: ACTIONS.UPDATE_PENDING_CLAIMS, + data: { + claims: [repostClaim], + }, + }); dispatch(doFetchClaimListMine(1, 10)); resolve(repostClaim); diff --git a/src/redux/selectors/claims.js b/src/redux/selectors/claims.js index c472543..34f3fac 100644 --- a/src/redux/selectors/claims.js +++ b/src/redux/selectors/claims.js @@ -555,6 +555,20 @@ export const selectChannelClaimCounts = createSelector( state => state.channelClaimCounts || {} ); +export const makeSelectPendingClaimUrlForName = (name: string) => + createSelector( + selectPendingIds, + selectClaimsById, + (pending, claims) => { + const pendingClaims = pending.map(id => claims[id]); + const matchingClaim = pendingClaims.find(claim => { + const { streamName } = parseURI(claim.permanent_url); + return name === streamName; + }); + return matchingClaim && matchingClaim.permanent_url; + } + ); + export const makeSelectTotalItemsForChannel = (uri: string) => createSelector( selectChannelClaimCounts, -- 2.45.2 From 612acc6e7f67d8180a3dd5ab1dd70f4f30ced60d Mon Sep 17 00:00:00 2001 From: zeppi Date: Fri, 4 Dec 2020 10:10:17 -0500 Subject: [PATCH 2/5] allow undefined channel_id in repost flowtype --- dist/flow-typed/Lbry.js | 2 +- flow-typed/Lbry.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/dist/flow-typed/Lbry.js b/dist/flow-typed/Lbry.js index 77a8831..a134a3c 100644 --- a/dist/flow-typed/Lbry.js +++ b/dist/flow-typed/Lbry.js @@ -232,7 +232,7 @@ declare type StreamRepostOptions = { name: string, bid: string, claim_id: string, - channel_id: string, + channel_id?: string, }; declare type StreamRepostResponse = GenericTxResponse; diff --git a/flow-typed/Lbry.js b/flow-typed/Lbry.js index 77a8831..a134a3c 100644 --- a/flow-typed/Lbry.js +++ b/flow-typed/Lbry.js @@ -232,7 +232,7 @@ declare type StreamRepostOptions = { name: string, bid: string, claim_id: string, - channel_id: string, + channel_id?: string, }; declare type StreamRepostResponse = GenericTxResponse; -- 2.45.2 From f683af3b99a1c891e44755d9b0410b854643a78d Mon Sep 17 00:00:00 2001 From: zeppi Date: Thu, 10 Dec 2020 23:03:32 -0500 Subject: [PATCH 3/5] add selectEffectiveAmountForUri --- dist/bundle.es.js | 5 +++++ src/index.js | 1 + src/redux/selectors/claims.js | 16 ++++++++++++---- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/dist/bundle.es.js b/dist/bundle.es.js index 6e19967..1ea52f5 100644 --- a/dist/bundle.es.js +++ b/dist/bundle.es.js @@ -2363,6 +2363,10 @@ const makeSelectAmountForUri = uri => reselect.createSelector(makeSelectClaimFor return claim && claim.amount; }); +const makeSelectEffectiveAmountForUri = uri => reselect.createSelector(makeSelectClaimForUri(uri), claim => { + return claim && claim.meta && claim.meta.effective_amount; +}); + const makeSelectContentTypeForUri = uri => reselect.createSelector(makeSelectClaimForUri(uri), claim => { const source = claim && claim.value && claim.value.source; return source ? source.media_type : undefined; @@ -6218,6 +6222,7 @@ exports.makeSelectCoverForUri = makeSelectCoverForUri; exports.makeSelectDateForUri = makeSelectDateForUri; exports.makeSelectDownloadPathForUri = makeSelectDownloadPathForUri; exports.makeSelectDownloadingForUri = makeSelectDownloadingForUri; +exports.makeSelectEffectiveAmountForUri = makeSelectEffectiveAmountForUri; exports.makeSelectFetchingChannelClaims = makeSelectFetchingChannelClaims; exports.makeSelectFileInfoForUri = makeSelectFileInfoForUri; exports.makeSelectFileNameForUri = makeSelectFileNameForUri; diff --git a/src/index.js b/src/index.js index 95254e4..e7d0864 100644 --- a/src/index.js +++ b/src/index.js @@ -157,6 +157,7 @@ export { makeSelectTitleForUri, makeSelectDateForUri, makeSelectAmountForUri, + makeSelectEffectiveAmountForUri, makeSelectTagsForUri, makeSelectTagInClaimOrChannelForUri, makeSelectContentTypeForUri, diff --git a/src/redux/selectors/claims.js b/src/redux/selectors/claims.js index 34f3fac..e3801be 100644 --- a/src/redux/selectors/claims.js +++ b/src/redux/selectors/claims.js @@ -258,8 +258,8 @@ export const makeSelectMyPurchasesForPage = (query: ?string, page: number = 1) = const end = Number(page) * Number(PAGE_SIZE); return matchingFileInfos && matchingFileInfos.length ? matchingFileInfos - .slice(start, end) - .map(fileInfo => fileInfo.canonical_url || fileInfo.permanent_url) + .slice(start, end) + .map(fileInfo => fileInfo.canonical_url || fileInfo.permanent_url) : []; } ); @@ -365,8 +365,8 @@ export const makeSelectDateForUri = (uri: string) => (claim.value.release_time ? claim.value.release_time * 1000 : claim.meta && claim.meta.creation_timestamp - ? claim.meta.creation_timestamp * 1000 - : null); + ? claim.meta.creation_timestamp * 1000 + : null); if (!timestamp) { return undefined; } @@ -383,6 +383,14 @@ export const makeSelectAmountForUri = (uri: string) => } ); +export const makeSelectEffectiveAmountForUri = (uri: string) => + createSelector( + makeSelectClaimForUri(uri), + claim => { + return claim && claim.meta && claim.meta.effective_amount; + } + ); + export const makeSelectContentTypeForUri = (uri: string) => createSelector( makeSelectClaimForUri(uri), -- 2.45.2 From 4f57992762eb693c8070bebafdb3fd3ef3858610 Mon Sep 17 00:00:00 2001 From: zeppi Date: Sun, 13 Dec 2020 19:17:16 -0500 Subject: [PATCH 4/5] pending --- dist/bundle.es.js | 22 +++++++++++++++++----- src/index.js | 2 +- src/redux/selectors/claims.js | 34 ++++++++++++++++++++++++++-------- 3 files changed, 44 insertions(+), 14 deletions(-) diff --git a/dist/bundle.es.js b/dist/bundle.es.js index 1ea52f5..6d7e1a6 100644 --- a/dist/bundle.es.js +++ b/dist/bundle.es.js @@ -2461,13 +2461,25 @@ const selectPlayingUri = reselect.createSelector(selectState$1, state => state.p const selectChannelClaimCounts = reselect.createSelector(selectState$1, state => state.channelClaimCounts || {}); -const makeSelectPendingClaimUrlForName = name => reselect.createSelector(selectPendingIds, selectClaimsById, (pending, claims) => { +const makeSelectPendingClaimForUri = uri => reselect.createSelector(selectPendingIds, selectClaimsById, (pending, claims) => { + let uriIsChannel; + let uriStreamName; + let uriChannelName; + try { + ({ isChannel: uriIsChannel, streamName: uriStreamName, channelName: uriChannelName } = parseURI(uri)); + } catch (e) { + return null; + } const pendingClaims = pending.map(id => claims[id]); const matchingClaim = pendingClaims.find(claim => { - const { streamName } = parseURI(claim.permanent_url); - return name === streamName; + const { streamName, channelName, isChannel } = parseURI(claim.permanent_url); + if (isChannel) { + return channelName === uriChannelName; + } else { + return streamName === uriStreamName; + } }); - return matchingClaim && matchingClaim.permanent_url; + return matchingClaim || null; }); const makeSelectTotalItemsForChannel = uri => reselect.createSelector(selectChannelClaimCounts, byUri => byUri && byUri[uri]); @@ -6242,7 +6254,7 @@ exports.makeSelectNsfwCountForChannel = makeSelectNsfwCountForChannel; exports.makeSelectNsfwCountFromUris = makeSelectNsfwCountFromUris; exports.makeSelectOmittedCountForChannel = makeSelectOmittedCountForChannel; exports.makeSelectPendingAmountByUri = makeSelectPendingAmountByUri; -exports.makeSelectPendingClaimUrlForName = makeSelectPendingClaimUrlForName; +exports.makeSelectPendingClaimForUri = makeSelectPendingClaimForUri; exports.makeSelectPermanentUrlForUri = makeSelectPermanentUrlForUri; exports.makeSelectPublishFormValue = makeSelectPublishFormValue; exports.makeSelectReflectingClaimForUri = makeSelectReflectingClaimForUri; diff --git a/src/index.js b/src/index.js index e7d0864..842c347 100644 --- a/src/index.js +++ b/src/index.js @@ -162,7 +162,7 @@ export { makeSelectTagInClaimOrChannelForUri, makeSelectContentTypeForUri, makeSelectIsUriResolving, - makeSelectPendingClaimUrlForName, + makeSelectPendingClaimForUri, makeSelectTotalItemsForChannel, makeSelectTotalPagesForChannel, makeSelectNsfwCountFromUris, diff --git a/src/redux/selectors/claims.js b/src/redux/selectors/claims.js index e3801be..3b8574a 100644 --- a/src/redux/selectors/claims.js +++ b/src/redux/selectors/claims.js @@ -258,8 +258,8 @@ export const makeSelectMyPurchasesForPage = (query: ?string, page: number = 1) = const end = Number(page) * Number(PAGE_SIZE); return matchingFileInfos && matchingFileInfos.length ? matchingFileInfos - .slice(start, end) - .map(fileInfo => fileInfo.canonical_url || fileInfo.permanent_url) + .slice(start, end) + .map(fileInfo => fileInfo.canonical_url || fileInfo.permanent_url) : []; } ); @@ -365,8 +365,8 @@ export const makeSelectDateForUri = (uri: string) => (claim.value.release_time ? claim.value.release_time * 1000 : claim.meta && claim.meta.creation_timestamp - ? claim.meta.creation_timestamp * 1000 - : null); + ? claim.meta.creation_timestamp * 1000 + : null); if (!timestamp) { return undefined; } @@ -563,17 +563,35 @@ export const selectChannelClaimCounts = createSelector( state => state.channelClaimCounts || {} ); -export const makeSelectPendingClaimUrlForName = (name: string) => +export const makeSelectPendingClaimForUri = (uri: string) => createSelector( selectPendingIds, selectClaimsById, (pending, claims) => { + let validUri; + let uriIsChannel; + let uriStreamName; + let uriChannelName; + try { + ({ + isChannel: uriIsChannel, + streamName: uriStreamName, + channelName: uriChannelName, + } = parseURI(uri)); + validUri = true; + } catch (e) { + return null; + } const pendingClaims = pending.map(id => claims[id]); const matchingClaim = pendingClaims.find(claim => { - const { streamName } = parseURI(claim.permanent_url); - return name === streamName; + const { streamName, channelName, isChannel } = parseURI(claim.permanent_url); + if (isChannel) { + return channelName === uriChannelName; + } else { + return streamName === uriStreamName; + } }); - return matchingClaim && matchingClaim.permanent_url; + return matchingClaim || null; } ); -- 2.45.2 From 664df6237d777d7cce31e58479bc98563ea98cb9 Mon Sep 17 00:00:00 2001 From: zeppi Date: Tue, 15 Dec 2020 22:31:33 -0500 Subject: [PATCH 5/5] effective amount number --- dist/bundle.es.js | 8 ++++++-- src/redux/selectors/claims.js | 7 ++++++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/dist/bundle.es.js b/dist/bundle.es.js index 6d7e1a6..7d787e2 100644 --- a/dist/bundle.es.js +++ b/dist/bundle.es.js @@ -2364,7 +2364,7 @@ const makeSelectAmountForUri = uri => reselect.createSelector(makeSelectClaimFor }); const makeSelectEffectiveAmountForUri = uri => reselect.createSelector(makeSelectClaimForUri(uri), claim => { - return claim && claim.meta && claim.meta.effective_amount; + return claim && claim.meta && typeof claim.meta.effective_amount === 'string' && Number(claim.meta.effective_amount); }); const makeSelectContentTypeForUri = uri => reselect.createSelector(makeSelectClaimForUri(uri), claim => { @@ -2466,7 +2466,11 @@ const makeSelectPendingClaimForUri = uri => reselect.createSelector(selectPendin let uriStreamName; let uriChannelName; try { - ({ isChannel: uriIsChannel, streamName: uriStreamName, channelName: uriChannelName } = parseURI(uri)); + ({ + isChannel: uriIsChannel, + streamName: uriStreamName, + channelName: uriChannelName + } = parseURI(uri)); } catch (e) { return null; } diff --git a/src/redux/selectors/claims.js b/src/redux/selectors/claims.js index 3b8574a..1a8b29c 100644 --- a/src/redux/selectors/claims.js +++ b/src/redux/selectors/claims.js @@ -387,7 +387,12 @@ export const makeSelectEffectiveAmountForUri = (uri: string) => createSelector( makeSelectClaimForUri(uri), claim => { - return claim && claim.meta && claim.meta.effective_amount; + return ( + claim && + claim.meta && + typeof claim.meta.effective_amount === 'string' && + Number(claim.meta.effective_amount) + ); } ); -- 2.45.2