Use blank poster and advisory when preview is blocked by insufficient stake.
## Issue - Redo 5636: Disable video previews in comments/posts made by channels below a certain channel staked level - Closes 5738: expand video preview level requierment to markdown images also
This commit is contained in:
parent
2a31678632
commit
9d1cf97aef
4 changed files with 51 additions and 23 deletions
|
@ -5,6 +5,7 @@ import EmbedPlayButton from 'component/embedPlayButton';
|
||||||
import Button from 'component/button';
|
import Button from 'component/button';
|
||||||
import UriIndicator from 'component/uriIndicator';
|
import UriIndicator from 'component/uriIndicator';
|
||||||
import { INLINE_PLAYER_WRAPPER_CLASS } from 'component/fileRenderFloating/view';
|
import { INLINE_PLAYER_WRAPPER_CLASS } from 'component/fileRenderFloating/view';
|
||||||
|
import { SIMPLE_SITE } from 'config';
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
uri: string,
|
uri: string,
|
||||||
|
@ -12,7 +13,7 @@ type Props = {
|
||||||
children: React.Node,
|
children: React.Node,
|
||||||
description: ?string,
|
description: ?string,
|
||||||
isResolvingUri: boolean,
|
isResolvingUri: boolean,
|
||||||
doResolveUri: string => void,
|
doResolveUri: (string) => void,
|
||||||
blackListedOutpoints: Array<{
|
blackListedOutpoints: Array<{
|
||||||
txid: string,
|
txid: string,
|
||||||
nout: number,
|
nout: number,
|
||||||
|
@ -20,6 +21,7 @@ type Props = {
|
||||||
playingUri: ?PlayingUri,
|
playingUri: ?PlayingUri,
|
||||||
parentCommentId?: string,
|
parentCommentId?: string,
|
||||||
isMarkdownPost?: boolean,
|
isMarkdownPost?: boolean,
|
||||||
|
allowPreview?: boolean,
|
||||||
};
|
};
|
||||||
|
|
||||||
class ClaimLink extends React.Component<Props> {
|
class ClaimLink extends React.Component<Props> {
|
||||||
|
@ -46,7 +48,7 @@ class ClaimLink extends React.Component<Props> {
|
||||||
let blackListed = false;
|
let blackListed = false;
|
||||||
|
|
||||||
blackListed = blackListedOutpoints.some(
|
blackListed = blackListedOutpoints.some(
|
||||||
outpoint =>
|
(outpoint) =>
|
||||||
(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)
|
||||||
);
|
);
|
||||||
|
@ -63,7 +65,16 @@ class ClaimLink extends React.Component<Props> {
|
||||||
};
|
};
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { uri, claim, children, isResolvingUri, playingUri, parentCommentId, isMarkdownPost } = this.props;
|
const {
|
||||||
|
uri,
|
||||||
|
claim,
|
||||||
|
children,
|
||||||
|
isResolvingUri,
|
||||||
|
playingUri,
|
||||||
|
parentCommentId,
|
||||||
|
isMarkdownPost,
|
||||||
|
allowPreview,
|
||||||
|
} = this.props;
|
||||||
const isUnresolved = (!isResolvingUri && !claim) || !claim;
|
const isUnresolved = (!isResolvingUri && !claim) || !claim;
|
||||||
const isBlacklisted = this.isClaimBlackListed();
|
const isBlacklisted = this.isClaimBlackListed();
|
||||||
const isPlayingInline =
|
const isPlayingInline =
|
||||||
|
@ -88,9 +99,24 @@ class ClaimLink extends React.Component<Props> {
|
||||||
[INLINE_PLAYER_WRAPPER_CLASS]: isPlayingInline,
|
[INLINE_PLAYER_WRAPPER_CLASS]: isPlayingInline,
|
||||||
})}
|
})}
|
||||||
>
|
>
|
||||||
<EmbedPlayButton uri={uri} parentCommentId={parentCommentId} isMarkdownPost={isMarkdownPost} />
|
<EmbedPlayButton
|
||||||
|
uri={uri}
|
||||||
|
parentCommentId={parentCommentId}
|
||||||
|
isMarkdownPost={isMarkdownPost}
|
||||||
|
allowPreview={allowPreview}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
{(allowPreview || !SIMPLE_SITE) && (
|
||||||
<Button button="link" className="preview-link__url" label={uri} navigate={uri} />
|
<Button button="link" className="preview-link__url" label={uri} navigate={uri} />
|
||||||
|
)}
|
||||||
|
{!allowPreview && SIMPLE_SITE && (
|
||||||
|
<div className="preview-link__unavailable">
|
||||||
|
<p>
|
||||||
|
{__("This channel isn't staking enough LBRY Credits for link previews.")}{' '}
|
||||||
|
<Button button="link" label={__('Learn more')} href="https://odysee.com/@lbry:3f/levelsonodysee:c" />.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,16 +12,17 @@ type Props = {
|
||||||
uri: string,
|
uri: string,
|
||||||
thumbnail: string,
|
thumbnail: string,
|
||||||
claim: ?Claim,
|
claim: ?Claim,
|
||||||
doResolveUri: string => void,
|
doResolveUri: (string) => void,
|
||||||
doFetchCostInfoForUri: string => void,
|
doFetchCostInfoForUri: (string) => void,
|
||||||
costInfo: ?{ cost: number },
|
costInfo: ?{ cost: number },
|
||||||
floatingPlayerEnabled: boolean,
|
floatingPlayerEnabled: boolean,
|
||||||
doPlayUri: (string, ?boolean, ?boolean, (GetResponse) => void) => void,
|
doPlayUri: (string, ?boolean, ?boolean, (GetResponse) => void) => void,
|
||||||
doAnaltyicsPurchaseEvent: GetResponse => void,
|
doAnaltyicsPurchaseEvent: (GetResponse) => void,
|
||||||
parentCommentId?: string,
|
parentCommentId?: string,
|
||||||
isMarkdownPost: boolean,
|
isMarkdownPost: boolean,
|
||||||
doSetPlayingUri: ({}) => void,
|
doSetPlayingUri: ({}) => void,
|
||||||
renderMode: string,
|
renderMode: string,
|
||||||
|
allowPreview?: boolean,
|
||||||
};
|
};
|
||||||
|
|
||||||
export default function EmbedPlayButton(props: Props) {
|
export default function EmbedPlayButton(props: Props) {
|
||||||
|
@ -39,6 +40,7 @@ export default function EmbedPlayButton(props: Props) {
|
||||||
parentCommentId,
|
parentCommentId,
|
||||||
isMarkdownPost,
|
isMarkdownPost,
|
||||||
renderMode,
|
renderMode,
|
||||||
|
allowPreview,
|
||||||
} = props;
|
} = props;
|
||||||
const {
|
const {
|
||||||
push,
|
push,
|
||||||
|
@ -48,7 +50,7 @@ export default function EmbedPlayButton(props: Props) {
|
||||||
const hasResolvedUri = claim !== undefined;
|
const hasResolvedUri = claim !== undefined;
|
||||||
const hasCostInfo = costInfo !== undefined;
|
const hasCostInfo = costInfo !== undefined;
|
||||||
const disabled = !hasResolvedUri || !costInfo;
|
const disabled = !hasResolvedUri || !costInfo;
|
||||||
const canPlayInline = [RENDER_MODES.AUDIO, RENDER_MODES.VIDEO].includes(renderMode);
|
const canPlayInline = [RENDER_MODES.AUDIO, RENDER_MODES.VIDEO].includes(renderMode) && allowPreview;
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!hasResolvedUri) {
|
if (!hasResolvedUri) {
|
||||||
|
@ -69,7 +71,7 @@ export default function EmbedPlayButton(props: Props) {
|
||||||
const formattedUrl = formatLbryUrlForWeb(uri);
|
const formattedUrl = formatLbryUrlForWeb(uri);
|
||||||
push(formattedUrl);
|
push(formattedUrl);
|
||||||
} else {
|
} else {
|
||||||
doPlayUri(uri, undefined, undefined, fileInfo => {
|
doPlayUri(uri, undefined, undefined, (fileInfo) => {
|
||||||
let playingOptions: PlayingUri = { uri, pathname };
|
let playingOptions: PlayingUri = { uri, pathname };
|
||||||
if (parentCommentId) {
|
if (parentCommentId) {
|
||||||
playingOptions.source = 'comment';
|
playingOptions.source = 'comment';
|
||||||
|
@ -84,13 +86,15 @@ export default function EmbedPlayButton(props: Props) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const backgroundImage = allowPreview ? `url('${thumbnail.replace(/'/g, "\\'")}')` : '';
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
disabled={disabled}
|
disabled={disabled}
|
||||||
role="button"
|
role="button"
|
||||||
className="embed__inline-button"
|
className="embed__inline-button"
|
||||||
onClick={handleClick}
|
onClick={handleClick}
|
||||||
style={{ backgroundImage: `url('${thumbnail.replace(/'/g, "\\'")}')` }}
|
style={{ backgroundImage: backgroundImage }}
|
||||||
>
|
>
|
||||||
<FileViewerEmbeddedTitle uri={uri} isInApp />
|
<FileViewerEmbeddedTitle uri={uri} isInApp />
|
||||||
<Button
|
<Button
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
// @flow
|
// @flow
|
||||||
import { KNOWN_APP_DOMAINS, SIMPLE_SITE } from 'config';
|
import { KNOWN_APP_DOMAINS } from 'config';
|
||||||
import * as ICONS from 'constants/icons';
|
import * as ICONS from 'constants/icons';
|
||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
import { isURIValid } from 'lbry-redux';
|
import { isURIValid } from 'lbry-redux';
|
||||||
|
@ -98,25 +98,16 @@ function MarkdownLink(props: Props) {
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
} else if (!simpleLinks && ((protocol && protocol[0] === 'lbry:' && isURIValid(decodedUri)) || lbryUrlFromLink)) {
|
} else if (!simpleLinks && ((protocol && protocol[0] === 'lbry:' && isURIValid(decodedUri)) || lbryUrlFromLink)) {
|
||||||
element = allowPreview ? (
|
element = (
|
||||||
<ClaimLink
|
<ClaimLink
|
||||||
uri={lbryUrlFromLink || decodedUri}
|
uri={lbryUrlFromLink || decodedUri}
|
||||||
autoEmbed={embed}
|
autoEmbed={embed}
|
||||||
parentCommentId={parentCommentId}
|
parentCommentId={parentCommentId}
|
||||||
isMarkdownPost={isMarkdownPost}
|
isMarkdownPost={isMarkdownPost}
|
||||||
|
allowPreview={allowPreview}
|
||||||
>
|
>
|
||||||
{children}
|
{children}
|
||||||
</ClaimLink>
|
</ClaimLink>
|
||||||
) : (
|
|
||||||
<Button
|
|
||||||
button="link"
|
|
||||||
iconRight={isLbryLink ? undefined : ICONS.EXTERNAL}
|
|
||||||
title={SIMPLE_SITE ? __("This channel isn't staking enough LBRY Credits for link previews.") : children}
|
|
||||||
label={children}
|
|
||||||
className="button--external-link"
|
|
||||||
navigate={isLbryLink ? href : undefined}
|
|
||||||
href={isLbryLink ? undefined : href}
|
|
||||||
/>
|
|
||||||
);
|
);
|
||||||
} else if (
|
} else if (
|
||||||
simpleLinks ||
|
simpleLinks ||
|
||||||
|
|
|
@ -217,6 +217,13 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.preview-link__unavailable {
|
||||||
|
font-size: var(--font-small);
|
||||||
|
text-align: right;
|
||||||
|
font-style: italic;
|
||||||
|
color: var(--color-text-subtitle);
|
||||||
|
}
|
||||||
|
|
||||||
.preview-link {
|
.preview-link {
|
||||||
padding: 0;
|
padding: 0;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
|
|
Loading…
Reference in a new issue