2018-09-12 18:42:15 +02:00
|
|
|
// @flow
|
2018-11-26 02:21:25 +01:00
|
|
|
import * as ICONS from 'constants/icons';
|
|
|
|
import React from 'react';
|
2018-09-12 18:42:15 +02:00
|
|
|
import Button from 'component/button';
|
2018-10-04 15:39:14 +02:00
|
|
|
import CopyableText from 'component/copyableText';
|
2018-09-12 18:42:15 +02:00
|
|
|
|
|
|
|
type Props = {
|
2019-06-28 09:33:07 +02:00
|
|
|
claim: Claim,
|
2018-09-12 18:42:15 +02:00
|
|
|
onDone: () => void,
|
2018-10-04 15:39:14 +02:00
|
|
|
speechShareable: boolean,
|
2018-11-09 16:34:48 +01:00
|
|
|
isChannel: boolean,
|
2018-09-12 18:42:15 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
class SocialShare extends React.PureComponent<Props> {
|
2018-11-09 16:34:48 +01:00
|
|
|
static defaultProps = {
|
|
|
|
isChannel: false,
|
|
|
|
};
|
|
|
|
|
2018-09-12 18:42:15 +02:00
|
|
|
constructor(props: Props) {
|
|
|
|
super(props);
|
|
|
|
|
|
|
|
this.input = undefined;
|
|
|
|
}
|
|
|
|
|
|
|
|
input: ?HTMLInputElement;
|
|
|
|
|
|
|
|
render() {
|
2019-07-17 05:23:45 +02:00
|
|
|
const { claim } = this.props;
|
|
|
|
const { short_url: shortUrl } = claim;
|
2018-10-04 15:39:14 +02:00
|
|
|
const { speechShareable, onDone } = this.props;
|
2019-03-21 17:44:07 +01:00
|
|
|
|
2019-06-28 09:33:07 +02:00
|
|
|
const lbryTvPrefix = 'https://beta.lbry.tv/';
|
2019-04-22 23:13:17 +02:00
|
|
|
const lbryPrefix = 'https://open.lbry.com/';
|
2019-07-17 05:23:45 +02:00
|
|
|
const lbryUri = shortUrl.split('lbry://')[1];
|
|
|
|
const lbryTvUri = lbryUri.replace('#', '/');
|
2019-04-22 23:13:17 +02:00
|
|
|
const encodedLbryURL: string = `${lbryPrefix}${encodeURIComponent(lbryUri)}`;
|
2019-07-17 05:23:45 +02:00
|
|
|
const lbryURL: string = `${lbryPrefix}${lbryUri}`;
|
2019-06-28 09:33:07 +02:00
|
|
|
const encodedLbryTvUrl = `${lbryTvPrefix}${encodeURIComponent(lbryTvUri)}`;
|
|
|
|
const lbryTvUrl = `${lbryTvPrefix}${lbryTvUri}`;
|
2019-03-21 17:44:07 +01:00
|
|
|
|
2019-06-28 09:33:07 +02:00
|
|
|
const shareOnFb = __('Share on Facebook');
|
|
|
|
const shareOnTwitter = __('Share On Twitter');
|
2018-10-04 15:39:14 +02:00
|
|
|
|
2018-09-12 18:42:15 +02:00
|
|
|
return (
|
2019-01-14 19:40:06 +01:00
|
|
|
<React.Fragment>
|
2018-10-04 15:39:14 +02:00
|
|
|
{speechShareable && (
|
|
|
|
<div className="card__content">
|
2019-06-28 09:33:07 +02:00
|
|
|
<label className="card__subtitle">{__('Web link')}</label>
|
|
|
|
<CopyableText copyable={lbryTvUrl} />
|
2019-01-22 19:29:45 +01:00
|
|
|
<div className="card__actions card__actions--center">
|
2018-10-04 15:39:14 +02:00
|
|
|
<Button
|
2018-11-26 02:21:25 +01:00
|
|
|
icon={ICONS.FACEBOOK}
|
2019-06-28 09:33:07 +02:00
|
|
|
button="link"
|
|
|
|
description={shareOnFb}
|
|
|
|
href={`https://facebook.com/sharer/sharer.php?u=${encodedLbryTvUrl}`}
|
2018-10-04 15:39:14 +02:00
|
|
|
/>
|
|
|
|
<Button
|
2018-11-26 02:21:25 +01:00
|
|
|
icon={ICONS.TWITTER}
|
2019-06-28 09:33:07 +02:00
|
|
|
button="link"
|
|
|
|
description={shareOnTwitter}
|
|
|
|
href={`https://twitter.com/home?status=${encodedLbryTvUrl}`}
|
2018-10-04 15:39:14 +02:00
|
|
|
/>
|
2019-06-28 09:33:07 +02:00
|
|
|
<Button icon={ICONS.WEB} button="link" description={__('View on lbry.tv')} href={`${lbryTvUrl}`} />
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
)}
|
|
|
|
<div className="card__content">
|
|
|
|
<label className="card__subtitle">{__('LBRY App link')}</label>
|
|
|
|
<CopyableText copyable={lbryURL} noSnackbar />
|
|
|
|
<div className="card__actions card__actions--center">
|
|
|
|
<Button
|
|
|
|
icon={ICONS.FACEBOOK}
|
|
|
|
button="link"
|
|
|
|
description={shareOnFb}
|
|
|
|
href={`https://facebook.com/sharer/sharer.php?u=${encodedLbryURL}`}
|
|
|
|
/>
|
|
|
|
<Button
|
|
|
|
icon={ICONS.TWITTER}
|
|
|
|
button="link"
|
|
|
|
description={shareOnTwitter}
|
|
|
|
href={`https://twitter.com/home?status=${encodedLbryURL}`}
|
|
|
|
/>
|
2018-10-04 15:39:14 +02:00
|
|
|
</div>
|
2018-09-26 19:48:07 +02:00
|
|
|
</div>
|
|
|
|
<div className="card__actions">
|
|
|
|
<Button button="link" label={__('Done')} onClick={onDone} />
|
2018-09-12 18:42:15 +02:00
|
|
|
</div>
|
2019-01-14 19:40:06 +01:00
|
|
|
</React.Fragment>
|
2018-09-12 18:42:15 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default SocialShare;
|