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,
|
||||
onDone: () => void,
|
||||
speechShareable: boolean,
|
||||
isChannel: boolean,
|
||||
};
|
||||
|
||||
class SocialShare extends React.PureComponent<Props> {
|
||||
static defaultProps = {
|
||||
isChannel: false,
|
||||
};
|
||||
|
||||
constructor(props: Props) {
|
||||
super(props);
|
||||
|
||||
|
@ -22,24 +27,33 @@ class SocialShare extends React.PureComponent<Props> {
|
|||
input: ?HTMLInputElement;
|
||||
|
||||
render() {
|
||||
const {
|
||||
claim_id: claimId,
|
||||
name: claimName,
|
||||
channel_name: channelName,
|
||||
value,
|
||||
} = this.props.claim;
|
||||
const { claim, isChannel } = this.props;
|
||||
const { claim_id: claimId, name: claimName, channel_name: channelName, value } = claim;
|
||||
|
||||
const { speechShareable, onDone } = this.props;
|
||||
const channelClaimId =
|
||||
value && value.publisherSignature && value.publisherSignature.certificateId;
|
||||
const speechPrefix = 'https://spee.ch/';
|
||||
const lbryPrefix = 'https://open.lbry.io/';
|
||||
|
||||
const speechURL =
|
||||
channelName && channelClaimId
|
||||
? `${speechPrefix}${channelName}:${channelClaimId}/${claimName}`
|
||||
: `${speechPrefix}${claimName}#${claimId}`;
|
||||
let speechURL;
|
||||
let lbryURL;
|
||||
if (isChannel) {
|
||||
// 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 (
|
||||
<section className="card__content">
|
||||
|
|
|
@ -7,14 +7,20 @@ type Props = {
|
|||
closeModal: () => void,
|
||||
uri: string,
|
||||
speechShareable: boolean,
|
||||
isChannel: boolean,
|
||||
};
|
||||
|
||||
class ModalSocialShare extends React.PureComponent<Props> {
|
||||
render() {
|
||||
const { closeModal, uri, speechShareable } = this.props;
|
||||
const { closeModal, uri, speechShareable, isChannel } = this.props;
|
||||
return (
|
||||
<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>
|
||||
);
|
||||
}
|
||||
|
|
|
@ -103,7 +103,12 @@ class ChannelPage extends React.PureComponent<Props> {
|
|||
button="alt"
|
||||
icon={icons.GLOBE}
|
||||
label={__('Share Channel')}
|
||||
onClick={() => openModal({ id: MODALS.SOCIAL_SHARE }, { uri, speechShareable: true })}
|
||||
onClick={() =>
|
||||
openModal(
|
||||
{ id: MODALS.SOCIAL_SHARE },
|
||||
{ uri, speechShareable: true, isChannel: true }
|
||||
)
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
<section className="card__content">{contentList}</section>
|
||||
|
|
Loading…
Reference in a new issue