From 990cbcab4daa0d93817aeb0c73b53848a068de73 Mon Sep 17 00:00:00 2001 From: zeppi Date: Thu, 25 Mar 2021 18:49:48 -0400 Subject: [PATCH] provide selector for placeholder stream --- dist/bundle.es.js | 9 +++++++++ src/index.js | 1 + src/redux/selectors/claims.js | 20 ++++++++++++++++---- 3 files changed, 26 insertions(+), 4 deletions(-) diff --git a/dist/bundle.es.js b/dist/bundle.es.js index efdf3de..bea23e1 100644 --- a/dist/bundle.es.js +++ b/dist/bundle.es.js @@ -2684,6 +2684,14 @@ const makeSelectClaimHasSource = uri => reselect.createSelector(makeSelectClaimF return Boolean(claim.value.source); }); +const makeSelectClaimIsStreamPlaceholder = uri => reselect.createSelector(makeSelectClaimForUri(uri), claim => { + if (!claim) { + return false; + } + + return Boolean(claim.value_type === 'stream' && !claim.value.source); +}); + const makeSelectTotalStakedAmountForChannelUri = uri => reselect.createSelector(makeSelectClaimForUri(uri), claim => { if (!claim || !claim.amount || !claim.meta || !claim.meta.support_amount) { return 0; @@ -6623,6 +6631,7 @@ exports.makeSelectClaimHasSource = makeSelectClaimHasSource; exports.makeSelectClaimIsMine = makeSelectClaimIsMine; exports.makeSelectClaimIsNsfw = makeSelectClaimIsNsfw; exports.makeSelectClaimIsPending = makeSelectClaimIsPending; +exports.makeSelectClaimIsStreamPlaceholder = makeSelectClaimIsStreamPlaceholder; exports.makeSelectClaimWasPurchased = makeSelectClaimWasPurchased; exports.makeSelectClaimsInChannelForCurrentPageState = makeSelectClaimsInChannelForCurrentPageState; exports.makeSelectClaimsInChannelForPage = makeSelectClaimsInChannelForPage; diff --git a/src/index.js b/src/index.js index 5545df1..24ec6fb 100644 --- a/src/index.js +++ b/src/index.js @@ -189,6 +189,7 @@ export { makeSelectAbandoningClaimById, makeSelectIsAbandoningClaimForUri, makeSelectClaimHasSource, + makeSelectClaimIsStreamPlaceholder, selectPendingIds, selectReflectingById, makeSelectClaimForClaimId, diff --git a/src/redux/selectors/claims.js b/src/redux/selectors/claims.js index e5af6ab..d7b151d 100644 --- a/src/redux/selectors/claims.js +++ b/src/redux/selectors/claims.js @@ -273,8 +273,8 @@ export const makeSelectMyPurchasesForPage = (query: ?string, page: number = 1) = const end = Number(page) * Number(CLAIM.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) : []; } ); @@ -380,8 +380,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; } @@ -871,6 +871,18 @@ export const makeSelectClaimHasSource = (uri: string) => } ); +export const makeSelectClaimIsStreamPlaceholder = (uri: string) => + createSelector( + makeSelectClaimForUri(uri), + claim => { + if (!claim) { + return false; + } + + return Boolean(claim.value_type === 'stream' && !claim.value.source); + } + ); + export const makeSelectTotalStakedAmountForChannelUri = (uri: string) => createSelector( makeSelectClaimForUri(uri),