Revert "Use blank poster and advisory when preview is blocked by insufficient stake."
This reverts commit 9d1cf97aef
.
This commit is contained in:
parent
e23a6f3cd6
commit
c73ba60ef5
4 changed files with 23 additions and 51 deletions
|
@ -5,7 +5,6 @@ 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,
|
||||||
|
@ -13,7 +12,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,
|
||||||
|
@ -21,7 +20,6 @@ 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> {
|
||||||
|
@ -48,7 +46,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)
|
||||||
);
|
);
|
||||||
|
@ -65,16 +63,7 @@ class ClaimLink extends React.Component<Props> {
|
||||||
};
|
};
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const {
|
const { uri, claim, children, isResolvingUri, playingUri, parentCommentId, isMarkdownPost } = this.props;
|
||||||
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 =
|
||||||
|
@ -99,24 +88,9 @@ class ClaimLink extends React.Component<Props> {
|
||||||
[INLINE_PLAYER_WRAPPER_CLASS]: isPlayingInline,
|
[INLINE_PLAYER_WRAPPER_CLASS]: isPlayingInline,
|
||||||
})}
|
})}
|
||||||
>
|
>
|
||||||
<EmbedPlayButton
|
<EmbedPlayButton uri={uri} parentCommentId={parentCommentId} isMarkdownPost={isMarkdownPost} />
|
||||||
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,17 +12,16 @@ 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) {
|
||||||
|
@ -40,7 +39,6 @@ export default function EmbedPlayButton(props: Props) {
|
||||||
parentCommentId,
|
parentCommentId,
|
||||||
isMarkdownPost,
|
isMarkdownPost,
|
||||||
renderMode,
|
renderMode,
|
||||||
allowPreview,
|
|
||||||
} = props;
|
} = props;
|
||||||
const {
|
const {
|
||||||
push,
|
push,
|
||||||
|
@ -50,7 +48,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) && allowPreview;
|
const canPlayInline = [RENDER_MODES.AUDIO, RENDER_MODES.VIDEO].includes(renderMode);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!hasResolvedUri) {
|
if (!hasResolvedUri) {
|
||||||
|
@ -71,7 +69,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';
|
||||||
|
@ -86,15 +84,13 @@ 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: backgroundImage }}
|
style={{ backgroundImage: `url('${thumbnail.replace(/'/g, "\\'")}')` }}
|
||||||
>
|
>
|
||||||
<FileViewerEmbeddedTitle uri={uri} isInApp />
|
<FileViewerEmbeddedTitle uri={uri} isInApp />
|
||||||
<Button
|
<Button
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
// @flow
|
// @flow
|
||||||
import { KNOWN_APP_DOMAINS } from 'config';
|
import { KNOWN_APP_DOMAINS, SIMPLE_SITE } 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,16 +98,25 @@ 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 = (
|
element = allowPreview ? (
|
||||||
<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,13 +217,6 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.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