Merge pull request #2096 from lbryio/social-links
Fix spee.ch and open.lbry.io links in social share
This commit is contained in:
commit
cf45aa6661
3 changed files with 39 additions and 14 deletions
|
@ -10,9 +10,14 @@ type Props = {
|
||||||
claim: Claim,
|
claim: Claim,
|
||||||
onDone: () => void,
|
onDone: () => void,
|
||||||
speechShareable: boolean,
|
speechShareable: boolean,
|
||||||
|
isChannel: boolean,
|
||||||
};
|
};
|
||||||
|
|
||||||
class SocialShare extends React.PureComponent<Props> {
|
class SocialShare extends React.PureComponent<Props> {
|
||||||
|
static defaultProps = {
|
||||||
|
isChannel: false,
|
||||||
|
};
|
||||||
|
|
||||||
constructor(props: Props) {
|
constructor(props: Props) {
|
||||||
super(props);
|
super(props);
|
||||||
|
|
||||||
|
@ -22,24 +27,33 @@ class SocialShare extends React.PureComponent<Props> {
|
||||||
input: ?HTMLInputElement;
|
input: ?HTMLInputElement;
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const {
|
const { claim, isChannel } = this.props;
|
||||||
claim_id: claimId,
|
const { claim_id: claimId, name: claimName, channel_name: channelName, value } = claim;
|
||||||
name: claimName,
|
|
||||||
channel_name: channelName,
|
|
||||||
value,
|
|
||||||
} = this.props.claim;
|
|
||||||
const { speechShareable, onDone } = this.props;
|
const { speechShareable, onDone } = this.props;
|
||||||
const channelClaimId =
|
const channelClaimId =
|
||||||
value && value.publisherSignature && value.publisherSignature.certificateId;
|
value && value.publisherSignature && value.publisherSignature.certificateId;
|
||||||
const speechPrefix = 'https://spee.ch/';
|
const speechPrefix = 'https://spee.ch/';
|
||||||
const lbryPrefix = 'https://open.lbry.io/';
|
const lbryPrefix = 'https://open.lbry.io/';
|
||||||
|
|
||||||
const speechURL =
|
let speechURL;
|
||||||
channelName && channelClaimId
|
let lbryURL;
|
||||||
? `${speechPrefix}${channelName}:${channelClaimId}/${claimName}`
|
if (isChannel) {
|
||||||
: `${speechPrefix}${claimName}#${claimId}`;
|
// For channel claims, the channel name (@something) is in `claim.name`
|
||||||
|
speechURL = `${speechPrefix}${claimName}:${claimId}`;
|
||||||
|
lbryURL = `${lbryPrefix}${claimName}#${claimId}`;
|
||||||
|
} else {
|
||||||
|
// If it's for a regular claim, check if it has an associated channel
|
||||||
|
speechURL =
|
||||||
|
channelName && channelClaimId
|
||||||
|
? `${speechPrefix}${channelName}:${channelClaimId}/${claimName}`
|
||||||
|
: `${speechPrefix}${claimId}/${claimName}`;
|
||||||
|
|
||||||
const lbryURL = `${lbryPrefix}${claimName}#${claimId}`;
|
lbryURL =
|
||||||
|
channelName && channelClaimId
|
||||||
|
? `${lbryPrefix}${channelName}#${channelClaimId}/${claimName}`
|
||||||
|
: `${lbryPrefix}${claimName}#${claimId}`;
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<section className="card__content">
|
<section className="card__content">
|
||||||
|
|
|
@ -7,14 +7,20 @@ type Props = {
|
||||||
closeModal: () => void,
|
closeModal: () => void,
|
||||||
uri: string,
|
uri: string,
|
||||||
speechShareable: boolean,
|
speechShareable: boolean,
|
||||||
|
isChannel: boolean,
|
||||||
};
|
};
|
||||||
|
|
||||||
class ModalSocialShare extends React.PureComponent<Props> {
|
class ModalSocialShare extends React.PureComponent<Props> {
|
||||||
render() {
|
render() {
|
||||||
const { closeModal, uri, speechShareable } = this.props;
|
const { closeModal, uri, speechShareable, isChannel } = this.props;
|
||||||
return (
|
return (
|
||||||
<Modal isOpen onAborted={closeModal} type="custom" title={__('Share')}>
|
<Modal isOpen onAborted={closeModal} type="custom" title={__('Share')}>
|
||||||
<SocialShare uri={uri} onDone={closeModal} speechShareable={speechShareable} />
|
<SocialShare
|
||||||
|
uri={uri}
|
||||||
|
onDone={closeModal}
|
||||||
|
speechShareable={speechShareable}
|
||||||
|
isChannel={isChannel}
|
||||||
|
/>
|
||||||
</Modal>
|
</Modal>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -103,7 +103,12 @@ class ChannelPage extends React.PureComponent<Props> {
|
||||||
button="alt"
|
button="alt"
|
||||||
icon={icons.GLOBE}
|
icon={icons.GLOBE}
|
||||||
label={__('Share Channel')}
|
label={__('Share Channel')}
|
||||||
onClick={() => openModal({ id: MODALS.SOCIAL_SHARE }, { uri, speechShareable: true })}
|
onClick={() =>
|
||||||
|
openModal(
|
||||||
|
{ id: MODALS.SOCIAL_SHARE },
|
||||||
|
{ uri, speechShareable: true, isChannel: true }
|
||||||
|
)
|
||||||
|
}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<section className="card__content">{contentList}</section>
|
<section className="card__content">{contentList}</section>
|
||||||
|
|
Loading…
Reference in a new issue