From 01f771c6ca0fdd0039f45671f457a5fe3abafd38 Mon Sep 17 00:00:00 2001 From: infinite-persistence Date: Wed, 17 Nov 2021 17:01:48 +0800 Subject: [PATCH] Simplify makeSelectViewersForId --- ui/component/fileTitleSection/index.js | 8 ++++---- ui/redux/selectors/livestream.js | 6 ++++-- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/ui/component/fileTitleSection/index.js b/ui/component/fileTitleSection/index.js index 7068ef02c..5fe1ed5fd 100644 --- a/ui/component/fileTitleSection/index.js +++ b/ui/component/fileTitleSection/index.js @@ -1,13 +1,13 @@ import { connect } from 'react-redux'; import { doFetchSubCount, selectSubCountForUri } from 'lbryinc'; -import { selectTitleForUri, makeSelectClaimForUri } from 'redux/selectors/claims'; +import { selectTitleForUri, selectClaimForUri } from 'redux/selectors/claims'; import { makeSelectInsufficientCreditsForUri } from 'redux/selectors/content'; -import { makeSelectViewersForId } from 'redux/selectors/livestream'; +import { selectViewersForId } from 'redux/selectors/livestream'; import FileTitleSection from './view'; const select = (state, props) => { - const claim = makeSelectClaimForUri(props.uri)(state); - const viewers = claim && makeSelectViewersForId(claim.claim_id)(state); + const claim = selectClaimForUri(state, props.uri); + const viewers = claim && selectViewersForId(state, claim.claim_id); const channelClaimId = claim && claim.signing_channel ? claim.signing_channel.claim_id : undefined; const channelUri = claim && claim.signing_channel ? claim.signing_channel.canonical_url : undefined; const subCount = channelUri && selectSubCountForUri(state, channelUri); diff --git a/ui/redux/selectors/livestream.js b/ui/redux/selectors/livestream.js index c5a55540a..ec963bde1 100644 --- a/ui/redux/selectors/livestream.js +++ b/ui/redux/selectors/livestream.js @@ -29,8 +29,10 @@ export const selectViewersById = (state: State) => selectState(state).viewersByI export const makeSelectIsFetchingLivestreams = (channelId: string) => createSelector(selectFetchingLivestreams, (fetchingLivestreams) => Boolean(fetchingLivestreams[channelId])); -export const makeSelectViewersForId = (channelId: string) => - createSelector(selectViewersById, (viewers) => viewers[channelId]); +export const selectViewersForId = (state: State, channelId: string) => { + const viewers = selectViewersById(state); + return viewers[channelId]; +}; export const makeSelectPendingLivestreamsForChannelId = (channelId: string) => createSelector(selectPendingClaims, (pendingClaims) => {