2020-04-14 01:48:11 +02:00
|
|
|
// @flow
|
|
|
|
import React from 'react';
|
|
|
|
import Button from 'component/button';
|
2021-09-21 17:48:05 +02:00
|
|
|
import * as ICONS from 'constants/icons';
|
2020-04-14 01:48:11 +02:00
|
|
|
import { formatLbryUrlForWeb } from 'util/url';
|
|
|
|
import { withRouter } from 'react-router';
|
2020-10-01 22:59:11 +02:00
|
|
|
import { URL, SITE_NAME } from 'config';
|
2021-07-26 00:03:48 +02:00
|
|
|
import Logo from 'component/logo';
|
2020-04-14 01:48:11 +02:00
|
|
|
|
|
|
|
type Props = {
|
|
|
|
uri: string,
|
|
|
|
isAuthenticated: boolean,
|
2021-09-18 16:23:30 +02:00
|
|
|
preferEmbed: boolean,
|
2020-04-14 01:48:11 +02:00
|
|
|
};
|
|
|
|
|
2020-04-29 20:35:55 +02:00
|
|
|
function FileViewerEmbeddedEnded(props: Props) {
|
2021-09-18 16:23:30 +02:00
|
|
|
const { uri, isAuthenticated, preferEmbed } = props;
|
2020-04-14 01:48:11 +02:00
|
|
|
|
|
|
|
const prompts = isAuthenticated
|
|
|
|
? {
|
2020-10-01 22:59:11 +02:00
|
|
|
discuss_auth: `Continue the discussion on ${SITE_NAME}`,
|
2020-04-14 01:48:11 +02:00
|
|
|
tip_auth: 'Always tip your creators',
|
|
|
|
}
|
|
|
|
: {
|
|
|
|
bigtech_unauth: 'Together, we can take back control from big tech',
|
2020-10-01 22:59:11 +02:00
|
|
|
discuss_unauth: `Continue the discussion on ${SITE_NAME}`,
|
|
|
|
find_unauth: `Find more great content on ${SITE_NAME}`,
|
2020-04-14 01:48:11 +02:00
|
|
|
a_b_unauth: "We test a lot of messages here. Wouldn't it be funny if the one telling you that did the best?",
|
2020-10-01 22:59:11 +02:00
|
|
|
earn_unauth: `Join ${SITE_NAME} and earn to watch.`,
|
2020-04-14 01:48:11 +02:00
|
|
|
blockchain_unauth: "Now if anyone asks, you can say you've used a blockchain.",
|
|
|
|
};
|
|
|
|
|
|
|
|
const promptKeys = Object.keys(prompts);
|
|
|
|
const promptKey = promptKeys[Math.floor(Math.random() * promptKeys.length)];
|
2020-10-01 22:59:11 +02:00
|
|
|
// $FlowFixMe
|
2020-04-14 01:48:11 +02:00
|
|
|
const prompt = prompts[promptKey];
|
2022-03-28 20:37:16 +02:00
|
|
|
const odyseeLink = `${URL}${formatLbryUrlForWeb(uri)}?src=${promptKey}`;
|
2021-09-21 17:48:05 +02:00
|
|
|
const showReplay = Boolean(window.player);
|
2020-04-14 01:48:11 +02:00
|
|
|
|
|
|
|
return (
|
|
|
|
<div className="file-viewer__overlay">
|
|
|
|
<div className="file-viewer__overlay-secondary">
|
2021-09-18 16:23:30 +02:00
|
|
|
<Button className="file-viewer__overlay-logo" href={URL} disabled={preferEmbed}>
|
2021-09-15 17:28:45 +02:00
|
|
|
<Logo type={'embed'} />
|
2021-07-26 00:03:48 +02:00
|
|
|
</Button>
|
2020-04-14 01:48:11 +02:00
|
|
|
</div>
|
2021-09-21 18:47:56 +02:00
|
|
|
|
|
|
|
<div className="file-viewer__overlay-title file-viewer_embed-ended-title">
|
|
|
|
<p>{prompt}</p>
|
|
|
|
</div>
|
|
|
|
<div className="file-viewer__overlay-actions">
|
2021-09-18 16:23:30 +02:00
|
|
|
<>
|
2021-09-21 18:47:56 +02:00
|
|
|
{showReplay && (
|
|
|
|
<Button
|
|
|
|
title={__('Replay')}
|
|
|
|
button="link"
|
|
|
|
label={preferEmbed ? __('Replay') : undefined}
|
|
|
|
iconRight={ICONS.REPLAY}
|
|
|
|
onClick={() => {
|
|
|
|
if (window.player) window.player.play();
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
)}
|
|
|
|
{!preferEmbed && (
|
2021-09-18 16:23:30 +02:00
|
|
|
<>
|
2022-03-28 20:37:16 +02:00
|
|
|
<a target="_blank" rel="noopener noreferrer" href={odyseeLink}>
|
|
|
|
<Button label={__('Discuss')} iconRight={ICONS.EXTERNAL} button="primary" />
|
|
|
|
</a>
|
2021-09-18 16:23:30 +02:00
|
|
|
{!isAuthenticated && (
|
2022-03-28 20:37:16 +02:00
|
|
|
<a target="_blank" rel="noopener noreferrer" href={`${URL}/$/signup?src=embed_signup`}>
|
|
|
|
<Button label={__('Join %SITE_NAME%', { SITE_NAME })} button="secondary" />
|
|
|
|
</a>
|
2021-09-18 16:23:30 +02:00
|
|
|
)}
|
|
|
|
</>
|
2021-09-21 18:47:56 +02:00
|
|
|
)}
|
2021-09-18 16:23:30 +02:00
|
|
|
</>
|
2021-09-21 18:47:56 +02:00
|
|
|
</div>
|
2020-04-14 01:48:11 +02:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2020-04-29 20:35:55 +02:00
|
|
|
export default withRouter(FileViewerEmbeddedEnded);
|