From 9e1359610460f42b3f79e67a72b70fea68798ed7 Mon Sep 17 00:00:00 2001 From: infinite-persistence Date: Mon, 24 May 2021 16:52:30 +0800 Subject: [PATCH] Fix 5932 "no way to buy Paid Images or Posts" - FileRenderInitiator: we don't display if it's not Audio or Video ("playables"). But only do that if it's free or was purchased, otherwise there's no button to buy it. - FileRenderInline: if the user have not purchased it, don't show anything (not even the spinner). --- ui/component/fileRenderInitiator/view.jsx | 4 +++- ui/component/fileRenderInline/index.js | 5 ++++- ui/component/fileRenderInline/view.jsx | 19 ++++++++++++++++++- 3 files changed, 25 insertions(+), 3 deletions(-) diff --git a/ui/component/fileRenderInitiator/view.jsx b/ui/component/fileRenderInitiator/view.jsx index ee761c1c4..5034356cd 100644 --- a/ui/component/fileRenderInitiator/view.jsx +++ b/ui/component/fileRenderInitiator/view.jsx @@ -120,7 +120,9 @@ export default function FileRenderInitiator(props: Props) { but for playables, always render so area can be used to fill with floating player */ if (isPlaying && !isPlayable) { - return null; + if (isFree || claimWasPurchased) { + return null; + } } const showAppNag = IS_WEB && RENDER_MODES.UNSUPPORTED_IN_THIS_APP.includes(renderMode); diff --git a/ui/component/fileRenderInline/index.js b/ui/component/fileRenderInline/index.js index 326144329..83b1f4b53 100644 --- a/ui/component/fileRenderInline/index.js +++ b/ui/component/fileRenderInline/index.js @@ -1,16 +1,19 @@ import { connect } from 'react-redux'; -import { makeSelectFileInfoForUri, makeSelectStreamingUrlForUri } from 'lbry-redux'; +import { makeSelectFileInfoForUri, makeSelectStreamingUrlForUri, makeSelectClaimWasPurchased } from 'lbry-redux'; import { doClaimEligiblePurchaseRewards } from 'redux/actions/rewards'; import { makeSelectFileRenderModeForUri, selectPrimaryUri } from 'redux/selectors/content'; import { withRouter } from 'react-router'; import { doAnalyticsView } from 'redux/actions/app'; import FileRenderInline from './view'; +import { makeSelectCostInfoForUri } from 'lbryinc'; const select = (state, props) => ({ fileInfo: makeSelectFileInfoForUri(props.uri)(state), isPlaying: selectPrimaryUri(state) === props.uri, streamingUrl: makeSelectStreamingUrlForUri(props.uri)(state), renderMode: makeSelectFileRenderModeForUri(props.uri)(state), + costInfo: makeSelectCostInfoForUri(props.uri)(state), + claimWasPurchased: makeSelectClaimWasPurchased(props.uri)(state), }); const perform = (dispatch) => ({ diff --git a/ui/component/fileRenderInline/view.jsx b/ui/component/fileRenderInline/view.jsx index 58e06ab2d..534ff4814 100644 --- a/ui/component/fileRenderInline/view.jsx +++ b/ui/component/fileRenderInline/view.jsx @@ -12,11 +12,24 @@ type Props = { streamingUrl?: string, triggerAnalyticsView: (string, number) => Promise, claimRewards: () => void, + costInfo: any, + claimWasPurchased: boolean, }; export default function FileRenderInline(props: Props) { - const { isPlaying, fileInfo, uri, streamingUrl, triggerAnalyticsView, claimRewards, renderMode } = props; + const { + isPlaying, + fileInfo, + uri, + streamingUrl, + triggerAnalyticsView, + claimRewards, + renderMode, + costInfo, + claimWasPurchased, + } = props; const [playTime, setPlayTime] = useState(); + const isFree = !costInfo || (costInfo.cost !== undefined && costInfo.cost === 0); const isReadyToView = fileInfo && fileInfo.completed; const isReadyToPlay = streamingUrl || isReadyToView; @@ -52,5 +65,9 @@ export default function FileRenderInline(props: Props) { return null; } + if (!isFree && !claimWasPurchased) { + return null; + } + return renderContent ? : ; }