Merge pull request #4228 from lbryio/fixEmbedsAfterPaidContent

Fix embeds after paid content
This commit is contained in:
jessopb 2020-05-21 17:30:30 -04:00 committed by GitHub
commit c6b649f2a5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 4 deletions

View file

@ -142,7 +142,7 @@ export default function FileRenderInitiator(props: Props) {
)}
{!disabled && (
<Button
requiresAuth={IS_WEB}
requiresAuth={shouldRedirect}
onClick={viewFile}
iconSize={30}
title={isPlayable ? __('Play') : __('View')}

View file

@ -1,6 +1,7 @@
import { connect } from 'react-redux';
import EmbedWrapperPage from './view';
import { doResolveUri, makeSelectClaimForUri, buildURI } from 'lbry-redux';
import { doPlayUri } from 'redux/actions/content';
const select = (state, props) => {
const { match } = props;
@ -16,6 +17,7 @@ const select = (state, props) => {
const perform = dispatch => {
return {
resolveUri: uri => dispatch(doResolveUri(uri)),
doPlayUri: uri => dispatch(doPlayUri(uri)),
};
};

View file

@ -6,17 +6,22 @@ type Props = {
uri: string,
resolveUri: string => void,
claim: Claim,
doPlayUri: string => void,
};
// $FlowFixMe apparently flow thinks this is wrong.
export const EmbedContext = React.createContext();
const EmbedWrapperPage = (props: Props) => {
const { resolveUri, claim, uri } = props;
const { resolveUri, claim, uri, doPlayUri } = props;
const haveClaim = Boolean(claim);
useEffect(() => {
if (resolveUri && uri) {
if (resolveUri && uri && !haveClaim) {
resolveUri(uri);
}
}, [resolveUri, uri]);
if (uri && haveClaim) {
doPlayUri(uri);
}
}, [resolveUri, uri, doPlayUri, haveClaim]);
return (
<div className={'embed__wrapper'}>