diff --git a/dist/bundle.es.js b/dist/bundle.es.js index 5e682c7..7d787e2 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 && typeof claim.meta.effective_amount === 'string' && Number(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; @@ -2457,6 +2461,31 @@ const selectPlayingUri = reselect.createSelector(selectState$1, state => state.p const selectChannelClaimCounts = reselect.createSelector(selectState$1, state => state.channelClaimCounts || {}); +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, channelName, isChannel } = parseURI(claim.permanent_url); + if (isChannel) { + return channelName === uriChannelName; + } else { + return streamName === uriStreamName; + } + }); + return matchingClaim || null; +}); + 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 +3713,12 @@ function doRepost(options) { repostClaim } }); + dispatch({ + type: UPDATE_PENDING_CLAIMS, + data: { + claims: [repostClaim] + } + }); dispatch(doFetchClaimListMine(1, 10)); resolve(repostClaim); @@ -6203,6 +6238,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; @@ -6222,6 +6258,7 @@ exports.makeSelectNsfwCountForChannel = makeSelectNsfwCountForChannel; exports.makeSelectNsfwCountFromUris = makeSelectNsfwCountFromUris; exports.makeSelectOmittedCountForChannel = makeSelectOmittedCountForChannel; exports.makeSelectPendingAmountByUri = makeSelectPendingAmountByUri; +exports.makeSelectPendingClaimForUri = makeSelectPendingClaimForUri; exports.makeSelectPermanentUrlForUri = makeSelectPermanentUrlForUri; exports.makeSelectPublishFormValue = makeSelectPublishFormValue; exports.makeSelectReflectingClaimForUri = makeSelectReflectingClaimForUri; @@ -6313,6 +6350,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/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; diff --git a/src/index.js b/src/index.js index 67410f2..842c347 100644 --- a/src/index.js +++ b/src/index.js @@ -157,10 +157,12 @@ export { makeSelectTitleForUri, makeSelectDateForUri, makeSelectAmountForUri, + makeSelectEffectiveAmountForUri, makeSelectTagsForUri, makeSelectTagInClaimOrChannelForUri, makeSelectContentTypeForUri, makeSelectIsUriResolving, + makeSelectPendingClaimForUri, makeSelectTotalItemsForChannel, makeSelectTotalPagesForChannel, makeSelectNsfwCountFromUris, @@ -181,6 +183,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..1a8b29c 100644 --- a/src/redux/selectors/claims.js +++ b/src/redux/selectors/claims.js @@ -383,6 +383,19 @@ export const makeSelectAmountForUri = (uri: string) => } ); +export const makeSelectEffectiveAmountForUri = (uri: string) => + createSelector( + makeSelectClaimForUri(uri), + claim => { + return ( + claim && + claim.meta && + typeof claim.meta.effective_amount === 'string' && + Number(claim.meta.effective_amount) + ); + } + ); + export const makeSelectContentTypeForUri = (uri: string) => createSelector( makeSelectClaimForUri(uri), @@ -555,6 +568,38 @@ export const selectChannelClaimCounts = createSelector( state => state.channelClaimCounts || {} ); +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, channelName, isChannel } = parseURI(claim.permanent_url); + if (isChannel) { + return channelName === uriChannelName; + } else { + return streamName === uriStreamName; + } + }); + return matchingClaim || null; + } + ); + export const makeSelectTotalItemsForChannel = (uri: string) => createSelector( selectChannelClaimCounts,