From d8dd860e0444c599dccf11fb8e82ed120a4d0f5a Mon Sep 17 00:00:00 2001 From: infinite-persistence Date: Thu, 9 Dec 2021 17:23:23 +0800 Subject: [PATCH] Livestream page prop optimization - Remove unused prop. - Use primitives whenever possible, since object references could change. --- ui/page/livestream/index.js | 9 +++------ ui/page/livestream/view.jsx | 6 +++--- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/ui/page/livestream/index.js b/ui/page/livestream/index.js index a4ab99d66..c477e5744 100644 --- a/ui/page/livestream/index.js +++ b/ui/page/livestream/index.js @@ -1,22 +1,19 @@ import { connect } from 'react-redux'; -import { makeSelectTagInClaimOrChannelForUri, makeSelectClaimForUri } from 'redux/selectors/claims'; -import { doResolveUri } from 'redux/actions/claims'; +import { makeSelectTagInClaimOrChannelForUri, selectClaimForUri } from 'redux/selectors/claims'; import { doSetPlayingUri } from 'redux/actions/content'; import { doUserSetReferrer } from 'redux/actions/user'; import { selectUserVerifiedEmail } from 'redux/selectors/user'; -import { selectHasUnclaimedRefereeReward } from 'redux/selectors/rewards'; import { DISABLE_COMMENTS_TAG } from 'constants/tags'; +import { getChannelIdFromClaim } from 'util/claim'; import LivestreamPage from './view'; const select = (state, props) => ({ - hasUnclaimedRefereeReward: selectHasUnclaimedRefereeReward(state), isAuthenticated: selectUserVerifiedEmail(state), - channelClaim: makeSelectClaimForUri(props.uri)(state), + channelClaimId: getChannelIdFromClaim(selectClaimForUri(state, props.uri)), chatDisabled: makeSelectTagInClaimOrChannelForUri(props.uri, DISABLE_COMMENTS_TAG)(state), }); export default connect(select, { doSetPlayingUri, - doResolveUri, doUserSetReferrer, })(LivestreamPage); diff --git a/ui/page/livestream/view.jsx b/ui/page/livestream/view.jsx index c121aa3cb..62a6c2c5f 100644 --- a/ui/page/livestream/view.jsx +++ b/ui/page/livestream/view.jsx @@ -14,14 +14,14 @@ type Props = { doSetPlayingUri: ({ uri: ?string }) => void, isAuthenticated: boolean, doUserSetReferrer: (string) => void, - channelClaim: ChannelClaim, + channelClaimId: ?string, chatDisabled: boolean, }; export default function LivestreamPage(props: Props) { - const { uri, claim, doSetPlayingUri, isAuthenticated, doUserSetReferrer, channelClaim, chatDisabled } = props; + const { uri, claim, doSetPlayingUri, isAuthenticated, doUserSetReferrer, channelClaimId, chatDisabled } = props; const [isLive, setIsLive] = React.useState('pending'); - const livestreamChannelId = channelClaim && channelClaim.signing_channel && channelClaim.signing_channel.claim_id; + const livestreamChannelId = channelClaimId; React.useEffect(() => { // TODO: This should not be needed one we unify the livestream player (?)