Make sure subCount gets called only once in FileTitleSection.
This commit is contained in:
parent
3375782a0e
commit
a5af6f8874
2 changed files with 10 additions and 7 deletions
|
@ -8,13 +8,16 @@ import FileTitleSection from './view';
|
|||
const select = (state, props) => {
|
||||
const claim = makeSelectClaimForUri(props.uri)(state);
|
||||
const viewers = claim && makeSelectViewersForId(claim.claim_id)(state);
|
||||
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 && makeSelectSubCountForUri(channelUri)(state);
|
||||
|
||||
return {
|
||||
claim,
|
||||
viewers,
|
||||
isInsufficientCredits: makeSelectInsufficientCreditsForUri(props.uri)(state),
|
||||
title: makeSelectTitleForUri(props.uri)(state),
|
||||
subCount: channelUri && makeSelectSubCountForUri(channelUri)(state),
|
||||
channelClaimId,
|
||||
subCount,
|
||||
};
|
||||
};
|
||||
|
||||
|
|
|
@ -16,7 +16,6 @@ import usePersistedState from 'effects/use-persisted-state';
|
|||
import { ENABLE_MATURE } from 'config';
|
||||
|
||||
type Props = {
|
||||
claim: ?Claim,
|
||||
uri: string,
|
||||
title: string,
|
||||
nsfw: boolean,
|
||||
|
@ -25,6 +24,7 @@ type Props = {
|
|||
isLive?: boolean,
|
||||
viewers?: number,
|
||||
subCount: number,
|
||||
channelClaimId?: string,
|
||||
fetchSubCount: (string) => void,
|
||||
};
|
||||
|
||||
|
@ -36,18 +36,18 @@ function FileTitleSection(props: Props) {
|
|||
isNsfwBlocked,
|
||||
livestream = false,
|
||||
isLive = false,
|
||||
claim,
|
||||
viewers,
|
||||
subCount,
|
||||
channelClaimId,
|
||||
fetchSubCount,
|
||||
} = props;
|
||||
const [hasAcknowledgedSec, setHasAcknowledgedSec] = usePersistedState('sec-nag', false);
|
||||
|
||||
React.useEffect(() => {
|
||||
if (claim && claim.signing_channel) {
|
||||
fetchSubCount(claim.signing_channel.claim_id);
|
||||
if (channelClaimId) {
|
||||
fetchSubCount(channelClaimId);
|
||||
}
|
||||
}, [claim, fetchSubCount]);
|
||||
}, [channelClaimId, fetchSubCount]);
|
||||
|
||||
return (
|
||||
<>
|
||||
|
|
Loading…
Add table
Reference in a new issue