improve embed events

This commit is contained in:
Rafael 2022-03-16 11:47:06 -03:00 committed by Thomas Zarebczan
parent b02f0736fc
commit 7400b9c12f

View file

@ -46,7 +46,7 @@ const EmbedWrapperPage = (props: Props) => {
isResolvingUri, isResolvingUri,
blackListedOutpoints, blackListedOutpoints,
isCurrentClaimLive, isCurrentClaimLive,
isLivestreamClaim: liveClaim, isLivestreamClaim,
claimThumbnail, claimThumbnail,
obscurePreview, obscurePreview,
doResolveUri, doResolveUri,
@ -87,7 +87,7 @@ const EmbedWrapperPage = (props: Props) => {
(signingChannel && outpoint.txid === signingChannel.txid && outpoint.nout === signingChannel.nout) || (signingChannel && outpoint.txid === signingChannel.txid && outpoint.nout === signingChannel.nout) ||
(outpoint.txid === claim.txid && outpoint.nout === claim.nout) (outpoint.txid === claim.txid && outpoint.nout === claim.nout)
); );
const isLiveClaimStopped = liveClaim && !readyToDisplay; const isLiveClaimStopped = isLivestreamClaim && !readyToDisplay;
React.useEffect(() => { React.useEffect(() => {
if (!claimThumbnail) return; if (!claimThumbnail) return;
@ -111,15 +111,15 @@ const EmbedWrapperPage = (props: Props) => {
}, [claimThumbnail, thumbnail]); }, [claimThumbnail, thumbnail]);
React.useEffect(() => { React.useEffect(() => {
if (doFetchActiveLivestreams) { if (doFetchActiveLivestreams && isLivestreamClaim) {
doFetchActiveLivestreams(); doFetchActiveLivestreams();
setLivestreamsFetched(true); setLivestreamsFetched(true);
} }
}, [doFetchActiveLivestreams]); }, [doFetchActiveLivestreams, isLivestreamClaim]);
// Establish web socket connection for viewer count. // Establish web socket connection for viewer count.
React.useEffect(() => { React.useEffect(() => {
if (!liveClaim || !claimId || !channelUrl || !canonicalUrl) return; if (!isLivestreamClaim || !claimId || !channelUrl || !canonicalUrl) return;
const channelName = formatLbryChannelName(channelUrl); const channelName = formatLbryChannelName(channelUrl);
@ -130,12 +130,13 @@ const EmbedWrapperPage = (props: Props) => {
doCommentSocketDisconnect(claimId, channelName); doCommentSocketDisconnect(claimId, channelName);
} }
}; };
}, [canonicalUrl, channelUrl, claimId, doCommentSocketConnect, doCommentSocketDisconnect, liveClaim]); }, [canonicalUrl, channelUrl, claimId, doCommentSocketConnect, doCommentSocketDisconnect, isLivestreamClaim]);
React.useEffect(() => { React.useEffect(() => {
if (doResolveUri && uri && !haveClaim) { if (doResolveUri && uri && !haveClaim) {
doResolveUri(uri); doResolveUri(uri);
} }
if (uri && haveClaim && costInfo && costInfo.cost === 0) { if (uri && haveClaim && costInfo && costInfo.cost === 0) {
doPlayUri(uri); doPlayUri(uri);
} }
@ -201,7 +202,9 @@ const EmbedWrapperPage = (props: Props) => {
<div className="embed__loading-text"> <div className="embed__loading-text">
{loading && <Spinner delayed light />} {loading && <Spinner delayed light />}
{noContentFound && <h1>{__('No content found.')}</h1>} {noContentFound && <h1>{__('No content found.')}</h1>}
{isPaidContent && ( {isPaidContent && (
<div> <div>
<h1>{__('Paid content cannot be embedded.')}</h1> <h1>{__('Paid content cannot be embedded.')}</h1>