From bb674b6e2c38e90d7f70039cb9d4cb2e5b836ce0 Mon Sep 17 00:00:00 2001 From: jessop Date: Thu, 21 May 2020 17:11:56 -0400 Subject: [PATCH] make embeds work --- ui/page/embedWrapper/index.js | 2 ++ ui/page/embedWrapper/view.jsx | 11 ++++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/ui/page/embedWrapper/index.js b/ui/page/embedWrapper/index.js index ab16697ed..6df9fab66 100644 --- a/ui/page/embedWrapper/index.js +++ b/ui/page/embedWrapper/index.js @@ -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)), }; }; diff --git a/ui/page/embedWrapper/view.jsx b/ui/page/embedWrapper/view.jsx index d3c343ad4..4089e10d6 100644 --- a/ui/page/embedWrapper/view.jsx +++ b/ui/page/embedWrapper/view.jsx @@ -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 (