feat: sub counts on own channels

- [ ] move to the bottom right of channel uri?
This commit is contained in:
Thomas Zarebczan 2019-09-24 23:42:51 -04:00 committed by Sean Yesmunt
parent fa1e538d5a
commit b80539bc7b
2 changed files with 16 additions and 1 deletions

View file

@ -9,7 +9,7 @@ import {
makeSelectClaimForUri, makeSelectClaimForUri,
selectChannelIsBlocked, selectChannelIsBlocked,
} from 'lbry-redux'; } from 'lbry-redux';
import { selectBlackListedOutpoints } from 'lbryinc'; import { selectBlackListedOutpoints, doFetchSubCount, makeSelectSubCountForUri } from 'lbryinc';
import { makeSelectIsSubscribed } from 'redux/selectors/subscriptions'; import { makeSelectIsSubscribed } from 'redux/selectors/subscriptions';
import { doOpenModal } from 'redux/actions/app'; import { doOpenModal } from 'redux/actions/app';
import { makeSelectClientSetting } from 'redux/selectors/settings'; import { makeSelectClientSetting } from 'redux/selectors/settings';
@ -26,10 +26,12 @@ const select = (state, props) => ({
channelIsBlocked: selectChannelIsBlocked(props.uri)(state), channelIsBlocked: selectChannelIsBlocked(props.uri)(state),
blackListedOutpoints: selectBlackListedOutpoints(state), blackListedOutpoints: selectBlackListedOutpoints(state),
supportOption: makeSelectClientSetting(settings.SUPPORT_OPTION)(state), supportOption: makeSelectClientSetting(settings.SUPPORT_OPTION)(state),
subCount: makeSelectSubCountForUri(props.uri)(state),
}); });
const perform = dispatch => ({ const perform = dispatch => ({
openModal: (modal, props) => dispatch(doOpenModal(modal, props)), openModal: (modal, props) => dispatch(doOpenModal(modal, props)),
fetchSubCount: claimId => dispatch(doFetchSubCount(claimId)),
}); });
export default connect( export default connect(

View file

@ -44,6 +44,8 @@ type Props = {
}>, }>,
openModal: (id: string, { uri: string, claimIsMine?: boolean, isSupport?: boolean }) => void, openModal: (id: string, { uri: string, claimIsMine?: boolean, isSupport?: boolean }) => void,
supportOption: boolean, supportOption: boolean,
fetchSubCount: string => void,
subCount: number,
}; };
function ChannelPage(props: Props) { function ChannelPage(props: Props) {
@ -62,6 +64,8 @@ function ChannelPage(props: Props) {
blackListedOutpoints, blackListedOutpoints,
openModal, openModal,
supportOption, supportOption,
fetchSubCount,
subCount,
} = props; } = props;
const { channelName } = parseURI(uri); const { channelName } = parseURI(uri);
@ -122,6 +126,10 @@ function ChannelPage(props: Props) {
); );
} }
if (channelIsMine) {
fetchSubCount(claim.claim_id);
}
React.useEffect(() => { React.useEffect(() => {
setSearchResults(null); setSearchResults(null);
setSearchQuery(''); setSearchQuery('');
@ -182,6 +190,11 @@ function ChannelPage(props: Props) {
<h2 className="channel__url"> <h2 className="channel__url">
<ClaimUri uri={uri} /> <ClaimUri uri={uri} />
</h2> </h2>
{channelIsMine && (
<span>
{subCount} {subCount !== 1 ? __('Subscribers') : __('Subscriber')}
</span>
)}
</div> </div>
</header> </header>
<Tabs onChange={onTabChange} index={tabIndex}> <Tabs onChange={onTabChange} index={tabIndex}>