make embeds work

This commit is contained in:
jessop 2020-05-21 17:11:56 -04:00
parent 6acf5c9ac4
commit bb674b6e2c
2 changed files with 10 additions and 3 deletions

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'}>