diff --git a/ui/component/claimInsufficientCredits/index.js b/ui/component/claimInsufficientCredits/index.js index e8326006c..d0acc38a3 100644 --- a/ui/component/claimInsufficientCredits/index.js +++ b/ui/component/claimInsufficientCredits/index.js @@ -1,11 +1,11 @@ import { connect } from 'react-redux'; import { selectInsufficientCreditsForUri } from 'redux/selectors/content'; -import { makeSelectClaimWasPurchased } from 'redux/selectors/claims'; +import { selectClaimWasPurchasedForUri } from 'redux/selectors/claims'; import ClaimInsufficientCredits from './view'; const select = (state, props) => ({ isInsufficientCredits: selectInsufficientCreditsForUri(state, props.uri), - claimWasPurchased: makeSelectClaimWasPurchased(props.uri)(state), + claimWasPurchased: selectClaimWasPurchasedForUri(state, props.uri), }); export default connect(select)(ClaimInsufficientCredits); diff --git a/ui/component/claimPreview/index.js b/ui/component/claimPreview/index.js index 65fb1a3d0..ce66b44d0 100644 --- a/ui/component/claimPreview/index.js +++ b/ui/component/claimPreview/index.js @@ -5,7 +5,6 @@ import { selectClaimIsMine, makeSelectClaimIsPending, makeSelectReflectingClaimForUri, - makeSelectClaimWasPurchased, selectTitleForUri, selectDateForUri, } from 'redux/selectors/claims'; @@ -45,7 +44,6 @@ const select = (state, props) => { hasVisitedUri: props.uri && makeSelectHasVisitedUri(props.uri)(state), isSubscribed: props.uri && selectIsSubscribedForUri(state, props.uri), streamingUrl: props.uri && makeSelectStreamingUrlForUri(props.uri)(state), - wasPurchased: props.uri && makeSelectClaimWasPurchased(props.uri)(state), isLivestream, isLivestreamActive: isLivestream && selectIsActiveLivestreamForUri(state, props.uri), livestreamViewerCount: isLivestream && claim ? selectViewersForId(state, claim.claim_id) : undefined, diff --git a/ui/component/fileDownloadLink/index.js b/ui/component/fileDownloadLink/index.js index 4042d6f3a..3c75e82b3 100644 --- a/ui/component/fileDownloadLink/index.js +++ b/ui/component/fileDownloadLink/index.js @@ -1,5 +1,5 @@ import { connect } from 'react-redux'; -import { selectClaimIsMine, selectClaimForUri, makeSelectClaimWasPurchased } from 'redux/selectors/claims'; +import { selectClaimIsMine, selectClaimForUri } from 'redux/selectors/claims'; import { makeSelectFileInfoForUri, makeSelectDownloadingForUri, @@ -21,7 +21,6 @@ const select = (state, props) => { claimIsMine: selectClaimIsMine(state, claim), claim, costInfo: selectCostInfoForUri(state, props.uri), - claimWasPurchased: makeSelectClaimWasPurchased(props.uri)(state), streamingUrl: makeSelectStreamingUrlForUri(props.uri)(state), }; }; diff --git a/ui/component/filePrice/index.js b/ui/component/filePrice/index.js index 3c816eb18..681a3bc5e 100644 --- a/ui/component/filePrice/index.js +++ b/ui/component/filePrice/index.js @@ -1,5 +1,5 @@ import { connect } from 'react-redux'; -import { selectClaimForUri, makeSelectClaimWasPurchased, selectClaimIsMine } from 'redux/selectors/claims'; +import { selectClaimForUri, selectClaimWasPurchasedForUri, selectClaimIsMine } from 'redux/selectors/claims'; import { selectCostInfoForUri, doFetchCostInfoForUri, selectFetchingCostInfoForUri } from 'lbryinc'; import FilePrice from './view'; @@ -9,7 +9,7 @@ const select = (state, props) => { return { claim, claimIsMine: selectClaimIsMine(state, claim), - claimWasPurchased: makeSelectClaimWasPurchased(props.uri)(state), + claimWasPurchased: selectClaimWasPurchasedForUri(state, props.uri), costInfo: selectCostInfoForUri(state, props.uri), fetching: selectFetchingCostInfoForUri(state, props.uri), }; diff --git a/ui/component/fileRenderFloating/index.js b/ui/component/fileRenderFloating/index.js index 2ccd84911..c99500694 100644 --- a/ui/component/fileRenderFloating/index.js +++ b/ui/component/fileRenderFloating/index.js @@ -2,7 +2,7 @@ import { connect } from 'react-redux'; import { selectClaimForUri, selectTitleForUri, - makeSelectClaimWasPurchased, + selectClaimWasPurchasedForUri, selectGeoRestrictionForUri, } from 'redux/selectors/claims'; import { makeSelectStreamingUrlForUri } from 'redux/selectors/file_info'; @@ -51,7 +51,7 @@ const select = (state, props) => { renderMode: makeSelectFileRenderModeForUri(uri)(state), videoTheaterMode: selectClientSetting(state, SETTINGS.VIDEO_THEATER_MODE), costInfo: selectCostInfoForUri(state, uri), - claimWasPurchased: makeSelectClaimWasPurchased(uri)(state), + claimWasPurchased: selectClaimWasPurchasedForUri(state, uri), nextListUri: collectionId && makeSelectNextUrlForCollectionAndUrl(collectionId, uri)(state), previousListUri: collectionId && makeSelectPreviousUrlForCollectionAndUrl(collectionId, uri)(state), collectionId, diff --git a/ui/component/fileRenderInitiator/index.js b/ui/component/fileRenderInitiator/index.js index 3703697d8..c2ae414be 100644 --- a/ui/component/fileRenderInitiator/index.js +++ b/ui/component/fileRenderInitiator/index.js @@ -1,6 +1,6 @@ import { connect } from 'react-redux'; import { doUriInitiatePlay } from 'redux/actions/content'; -import { makeSelectClaimWasPurchased, selectClaimForUri } from 'redux/selectors/claims'; +import { selectClaimWasPurchasedForUri, selectClaimForUri } from 'redux/selectors/claims'; import { makeSelectFileInfoForUri } from 'redux/selectors/file_info'; import * as SETTINGS from 'constants/settings'; import { selectCostInfoForUri } from 'lbryinc'; @@ -36,7 +36,7 @@ const select = (state, props) => { autoplay: selectClientSetting(state, SETTINGS.AUTOPLAY_MEDIA), costInfo: selectCostInfoForUri(state, uri), renderMode: makeSelectFileRenderModeForUri(uri)(state), - claimWasPurchased: makeSelectClaimWasPurchased(uri)(state), + claimWasPurchased: selectClaimWasPurchasedForUri(state, uri), authenticated: selectUserVerifiedEmail(state), isCurrentClaimLive: selectIsActiveLivestreamForUri(state, uri), isLivestreamClaim: isStreamPlaceholderClaim(claim), diff --git a/ui/component/fileRenderInline/index.js b/ui/component/fileRenderInline/index.js index a858d3639..808c4762b 100644 --- a/ui/component/fileRenderInline/index.js +++ b/ui/component/fileRenderInline/index.js @@ -1,6 +1,6 @@ import { connect } from 'react-redux'; import { makeSelectFileInfoForUri, makeSelectStreamingUrlForUri } from 'redux/selectors/file_info'; -import { makeSelectClaimWasPurchased } from 'redux/selectors/claims'; +import { selectClaimWasPurchasedForUri } from 'redux/selectors/claims'; import { doClaimEligiblePurchaseRewards } from 'redux/actions/rewards'; import { makeSelectFileRenderModeForUri, selectPrimaryUri } from 'redux/selectors/content'; import { withRouter } from 'react-router'; @@ -14,7 +14,7 @@ const select = (state, props) => ({ streamingUrl: makeSelectStreamingUrlForUri(props.uri)(state), renderMode: makeSelectFileRenderModeForUri(props.uri)(state), costInfo: selectCostInfoForUri(state, props.uri), - claimWasPurchased: makeSelectClaimWasPurchased(props.uri)(state), + claimWasPurchased: selectClaimWasPurchasedForUri(state, props.uri), }); const perform = (dispatch) => ({ diff --git a/ui/redux/actions/content.js b/ui/redux/actions/content.js index b572bce44..f6b6a755c 100644 --- a/ui/redux/actions/content.js +++ b/ui/redux/actions/content.js @@ -5,7 +5,7 @@ import * as MODALS from 'constants/modal_types'; import { ipcRenderer } from 'electron'; // @endif import { doOpenModal, doAnalyticsView, doAnaltyicsPurchaseEvent } from 'redux/actions/app'; -import { makeSelectClaimForUri, selectClaimIsMineForUri, makeSelectClaimWasPurchased } from 'redux/selectors/claims'; +import { makeSelectClaimForUri, selectClaimIsMineForUri, selectClaimWasPurchasedForUri } from 'redux/selectors/claims'; import { makeSelectFileInfoForUri, selectFileInfosByOutpoint, @@ -179,7 +179,7 @@ export function doPlayUri( const fileInfo = makeSelectFileInfoForUri(uri)(state); const uriIsStreamable = makeSelectUriIsStreamable(uri)(state); const downloadingByOutpoint = selectDownloadingByOutpoint(state); - const claimWasPurchased = makeSelectClaimWasPurchased(uri)(state); + const claimWasPurchased = selectClaimWasPurchasedForUri(state, uri); const alreadyDownloaded = fileInfo && (fileInfo.completed || (fileInfo.blobs_remaining === 0 && uriIsStreamable)); const alreadyDownloading = fileInfo && !!downloadingByOutpoint[fileInfo.outpoint]; diff --git a/ui/redux/selectors/claims.js b/ui/redux/selectors/claims.js index ffb892063..65de8726d 100644 --- a/ui/redux/selectors/claims.js +++ b/ui/redux/selectors/claims.js @@ -294,10 +294,9 @@ export const makeSelectMyPurchasesForPage = (query: ?string, page: number = 1) = } ); -export const makeSelectClaimWasPurchased = (uri: string) => - createSelector(makeSelectClaimForUri(uri), (claim) => { - return claim && claim.purchase_receipt !== undefined; - }); +export const selectClaimWasPurchasedForUri = createSelector(selectClaimForUri, (claim) => + Boolean(claim?.purchase_receipt !== undefined) +); export const selectAllFetchingChannelClaims = createSelector(selectState, (state) => state.fetchingChannelClaims || {});