From 26d7e9a2b655eac47284bd0c7ab30efef42d2c60 Mon Sep 17 00:00:00 2001 From: Rafael Date: Fri, 13 May 2022 09:04:26 -0300 Subject: [PATCH] Add share buttons on channel page --- ui/component/embedTextArea/view.jsx | 5 ++-- ui/component/socialShare/index.js | 26 ++++++++++++------- ui/component/socialShare/view.jsx | 39 +++++++++++++++++++++-------- ui/util/web.js | 14 +++++++++-- 4 files changed, 60 insertions(+), 24 deletions(-) diff --git a/ui/component/embedTextArea/view.jsx b/ui/component/embedTextArea/view.jsx index c10b4ce6a..472d040c3 100644 --- a/ui/component/embedTextArea/view.jsx +++ b/ui/component/embedTextArea/view.jsx @@ -14,14 +14,15 @@ type Props = { includeStartTime: boolean, startTime: number, referralCode: ?string, + newestType?: boolean, }; export default function EmbedTextArea(props: Props) { - const { doToast, snackMessage, label, claim, includeStartTime, startTime, referralCode } = props; + const { doToast, snackMessage, label, claim, includeStartTime, startTime, referralCode, newestType } = props; const { claim_id: claimId, name } = claim; const input = useRef(); - const streamUrl = generateEmbedUrl(name, claimId, includeStartTime && startTime, referralCode); + const streamUrl = generateEmbedUrl(name, claimId, includeStartTime && startTime, referralCode, newestType); const { html: embedText } = generateEmbedIframeData(streamUrl); function copyToClipboard() { diff --git a/ui/component/socialShare/index.js b/ui/component/socialShare/index.js index 230c79650..5ede340ca 100644 --- a/ui/component/socialShare/index.js +++ b/ui/component/socialShare/index.js @@ -1,18 +1,26 @@ import { connect } from 'react-redux'; import { doFetchInviteStatus } from 'redux/actions/user'; -import { makeSelectClaimForUri, selectTitleForUri } from 'redux/selectors/claims'; +import { selectClaimForUri, selectTitleForUri } from 'redux/selectors/claims'; import SocialShare from './view'; import { selectUserInviteReferralCode, selectUser, selectUserInviteStatusFetched } from 'redux/selectors/user'; import { selectContentPositionForUri } from 'redux/selectors/content'; +import { selectActiveLivestreamForChannel } from 'redux/selectors/livestream'; -const select = (state, props) => ({ - claim: makeSelectClaimForUri(props.uri)(state), - inviteStatusFetched: selectUserInviteStatusFetched(state), - referralCode: selectUserInviteReferralCode(state), - user: selectUser(state), - title: selectTitleForUri(state, props.uri), - position: selectContentPositionForUri(state, props.uri), -}); +const select = (state, props) => { + const { uri } = props; + const claim = selectClaimForUri(state, uri); + const { claim_id: claimId } = claim || {}; + + return { + claim, + inviteStatusFetched: selectUserInviteStatusFetched(state), + referralCode: selectUserInviteReferralCode(state), + user: selectUser(state), + title: selectTitleForUri(state, uri), + position: selectContentPositionForUri(state, uri), + hasActiveLivestream: Boolean(selectActiveLivestreamForChannel(state, claimId)), + }; +}; const perform = { doFetchInviteStatus, diff --git a/ui/component/socialShare/view.jsx b/ui/component/socialShare/view.jsx index 0a9571daa..63a03318e 100644 --- a/ui/component/socialShare/view.jsx +++ b/ui/component/socialShare/view.jsx @@ -1,11 +1,12 @@ // @flow import * as ICONS from 'constants/icons'; +import * as PAGES from 'constants/pages'; import React from 'react'; import Button from 'component/button'; import CopyableText from 'component/copyableText'; import EmbedTextArea from 'component/embedTextArea'; import Spinner from 'component/spinner'; -import { generateDownloadUrl } from 'util/web'; +import { generateDownloadUrl, generateNewestUrl } from 'util/web'; import { useIsMobile } from 'effects/use-screensize'; import { FormField } from 'component/common/form'; import { hmsToSeconds, secondsToHms } from 'util/time'; @@ -28,6 +29,7 @@ type Props = { user: any, position: number, collectionId?: number, + hasActiveLivestream: boolean, doFetchInviteStatus: (boolean) => void, }; @@ -41,6 +43,7 @@ function SocialShare(props: Props) { webShareable, position, collectionId, + hasActiveLivestream, doFetchInviteStatus, } = props; const [showEmbed, setShowEmbed] = React.useState(false); @@ -191,7 +194,7 @@ function SocialShare(props: Props) { title={__('Share on Facebook')} href={`https://facebook.com/sharer/sharer.php?u=${encodedLbryURL}`} /> - {webShareable && !isCollection && !isChannel && ( + {webShareable && !isCollection && (