Simplify makeSelectViewersForId

This commit is contained in:
infinite-persistence 2021-11-17 17:01:48 +08:00
parent 6b6879ba64
commit 01f771c6ca
No known key found for this signature in database
GPG key ID: B9C3252EDC3D0AA0
2 changed files with 8 additions and 6 deletions

View file

@ -1,13 +1,13 @@
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { doFetchSubCount, selectSubCountForUri } from 'lbryinc'; 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 { makeSelectInsufficientCreditsForUri } from 'redux/selectors/content';
import { makeSelectViewersForId } from 'redux/selectors/livestream'; import { selectViewersForId } from 'redux/selectors/livestream';
import FileTitleSection from './view'; import FileTitleSection from './view';
const select = (state, props) => { const select = (state, props) => {
const claim = makeSelectClaimForUri(props.uri)(state); const claim = selectClaimForUri(state, props.uri);
const viewers = claim && makeSelectViewersForId(claim.claim_id)(state); const viewers = claim && selectViewersForId(state, claim.claim_id);
const channelClaimId = claim && claim.signing_channel ? claim.signing_channel.claim_id : undefined; 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 channelUri = claim && claim.signing_channel ? claim.signing_channel.canonical_url : undefined;
const subCount = channelUri && selectSubCountForUri(state, channelUri); const subCount = channelUri && selectSubCountForUri(state, channelUri);

View file

@ -29,8 +29,10 @@ export const selectViewersById = (state: State) => selectState(state).viewersByI
export const makeSelectIsFetchingLivestreams = (channelId: string) => export const makeSelectIsFetchingLivestreams = (channelId: string) =>
createSelector(selectFetchingLivestreams, (fetchingLivestreams) => Boolean(fetchingLivestreams[channelId])); createSelector(selectFetchingLivestreams, (fetchingLivestreams) => Boolean(fetchingLivestreams[channelId]));
export const makeSelectViewersForId = (channelId: string) => export const selectViewersForId = (state: State, channelId: string) => {
createSelector(selectViewersById, (viewers) => viewers[channelId]); const viewers = selectViewersById(state);
return viewers[channelId];
};
export const makeSelectPendingLivestreamsForChannelId = (channelId: string) => export const makeSelectPendingLivestreamsForChannelId = (channelId: string) =>
createSelector(selectPendingClaims, (pendingClaims) => { createSelector(selectPendingClaims, (pendingClaims) => {