display follower and view counts #99
7 changed files with 54 additions and 11 deletions
|
@ -27,6 +27,7 @@ import {
|
||||||
homepageReducer,
|
homepageReducer,
|
||||||
rewardsReducer,
|
rewardsReducer,
|
||||||
selectUserVerifiedEmail,
|
selectUserVerifiedEmail,
|
||||||
|
statsReducer,
|
||||||
subscriptionsReducer,
|
subscriptionsReducer,
|
||||||
syncReducer,
|
syncReducer,
|
||||||
userReducer,
|
userReducer,
|
||||||
|
@ -141,6 +142,7 @@ const reducers = persistCombineReducers(persistOptions, {
|
||||||
rewards: rewardsReducer,
|
rewards: rewardsReducer,
|
||||||
settings: settingsReducer,
|
settings: settingsReducer,
|
||||||
search: searchReducer,
|
search: searchReducer,
|
||||||
|
stats: statsReducer,
|
||||||
subscriptions: subscriptionsReducer,
|
subscriptions: subscriptionsReducer,
|
||||||
sync: syncReducer,
|
sync: syncReducer,
|
||||||
tags: tagsReducer,
|
tags: tagsReducer,
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
import { doAbandonClaim, doFetchChannelListMine, makeSelectClaimForUri, selectMyChannelClaims } from 'lbry-redux';
|
import { doAbandonClaim, doFetchChannelListMine, makeSelectClaimForUri, selectMyChannelClaims } from 'lbry-redux';
|
||||||
|
import { doFetchSubCount, makeSelectSubCountForUri } from 'lbryinc';
|
||||||
import { doPopDrawerStack } from 'redux/actions/drawer';
|
import { doPopDrawerStack } from 'redux/actions/drawer';
|
||||||
import { doSetSortByItem, doSetTimeItem } from 'redux/actions/settings';
|
import { doSetSortByItem, doSetTimeItem } from 'redux/actions/settings';
|
||||||
import { selectDrawerStack } from 'redux/selectors/drawer';
|
import { selectDrawerStack } from 'redux/selectors/drawer';
|
||||||
|
@ -11,12 +12,14 @@ const select = (state, props) => ({
|
||||||
claim: makeSelectClaimForUri(props.uri)(state),
|
claim: makeSelectClaimForUri(props.uri)(state),
|
||||||
drawerStack: selectDrawerStack(state),
|
drawerStack: selectDrawerStack(state),
|
||||||
sortByItem: selectSortByItem(state),
|
sortByItem: selectSortByItem(state),
|
||||||
|
subCount: makeSelectSubCountForUri(props.uri)(state),
|
||||||
timeItem: selectTimeItem(state),
|
timeItem: selectTimeItem(state),
|
||||||
});
|
});
|
||||||
|
|
||||||
const perform = dispatch => ({
|
const perform = dispatch => ({
|
||||||
abandonClaim: (txid, nout) => dispatch(doAbandonClaim(txid, nout)),
|
abandonClaim: (txid, nout) => dispatch(doAbandonClaim(txid, nout)),
|
||||||
fetchChannelListMine: () => dispatch(doFetchChannelListMine()),
|
fetchChannelListMine: () => dispatch(doFetchChannelListMine()),
|
||||||
|
fetchSubCount: claimId => dispatch(doFetchSubCount(claimId)),
|
||||||
popDrawerStack: () => dispatch(doPopDrawerStack()),
|
popDrawerStack: () => dispatch(doPopDrawerStack()),
|
||||||
setSortByItem: item => dispatch(doSetSortByItem(item)),
|
setSortByItem: item => dispatch(doSetSortByItem(item)),
|
||||||
setTimeItem: item => dispatch(doSetTimeItem(item)),
|
setTimeItem: item => dispatch(doSetTimeItem(item)),
|
||||||
|
|
|
@ -49,9 +49,12 @@ class ChannelPage extends React.PureComponent {
|
||||||
}
|
}
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
const { fetchChannelListMine } = this.props;
|
const { claim, fetchChannelListMine, fetchSubCount } = this.props;
|
||||||
NativeModules.Firebase.setCurrentScreen('Channel');
|
NativeModules.Firebase.setCurrentScreen('Channel');
|
||||||
fetchChannelListMine();
|
fetchChannelListMine();
|
||||||
|
if (claim) {
|
||||||
|
fetchSubCount(claim.claim_id);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
handleSortByItemSelected = item => {
|
handleSortByItemSelected = item => {
|
||||||
|
@ -207,7 +210,7 @@ class ChannelPage extends React.PureComponent {
|
||||||
};
|
};
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { channels, claim, navigation, uri, drawerStack, popDrawerStack, timeItem } = this.props;
|
const { channels, claim, navigation, uri, drawerStack, popDrawerStack, subCount, timeItem } = this.props;
|
||||||
const { name, permanent_url: permanentUrl } = claim;
|
const { name, permanent_url: permanentUrl } = claim;
|
||||||
const { autoStyle, currentSortByItem, showSortPicker, showTimePicker } = this.state;
|
const { autoStyle, currentSortByItem, showSortPicker, showTimePicker } = this.state;
|
||||||
const ownedChannel = channels ? channels.map(channel => channel.permanent_url).includes(permanentUrl) : false;
|
const ownedChannel = channels ? channels.map(channel => channel.permanent_url).includes(permanentUrl) : false;
|
||||||
|
@ -252,6 +255,10 @@ class ChannelPage extends React.PureComponent {
|
||||||
|
|
||||||
<View style={channelPageStyle.channelHeader}>
|
<View style={channelPageStyle.channelHeader}>
|
||||||
<Text style={channelPageStyle.channelName}>{title && title.trim().length > 0 ? title : name}</Text>
|
<Text style={channelPageStyle.channelName}>{title && title.trim().length > 0 ? title : name}</Text>
|
||||||
|
<Text style={channelPageStyle.followerCount}>
|
||||||
|
{subCount === 1 && __('%follower% follower', { follower: subCount })}
|
||||||
|
{subCount > 1 && __('%follower% followers', { follower: subCount })}
|
||||||
|
</Text>
|
||||||
</View>
|
</View>
|
||||||
|
|
||||||
<View style={[channelPageStyle.avatarImageContainer, autoStyle]}>
|
<View style={[channelPageStyle.avatarImageContainer, autoStyle]}>
|
||||||
|
|
|
@ -33,7 +33,9 @@ import {
|
||||||
import {
|
import {
|
||||||
doClaimEligiblePurchaseRewards,
|
doClaimEligiblePurchaseRewards,
|
||||||
doFetchCostInfoForUri,
|
doFetchCostInfoForUri,
|
||||||
|
doFetchViewCount,
|
||||||
makeSelectCostInfoForUri,
|
makeSelectCostInfoForUri,
|
||||||
|
makeSelectViewCountForUri,
|
||||||
selectRewardContentClaimIds,
|
selectRewardContentClaimIds,
|
||||||
selectBlackListedOutpoints,
|
selectBlackListedOutpoints,
|
||||||
} from 'lbryinc';
|
} from 'lbryinc';
|
||||||
|
@ -76,6 +78,7 @@ const select = (state, props) => {
|
||||||
title: makeSelectTitleForUri(contentUri)(state),
|
title: makeSelectTitleForUri(contentUri)(state),
|
||||||
recommendedContent: makeSelectRecommendedContentForUri(contentUri)(state),
|
recommendedContent: makeSelectRecommendedContentForUri(contentUri)(state),
|
||||||
isSearchingRecommendContent: selectIsSearching(state),
|
isSearchingRecommendContent: selectIsSearching(state),
|
||||||
|
viewCount: makeSelectViewCountForUri(contentUri)(state),
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -89,6 +92,7 @@ const perform = dispatch => ({
|
||||||
fetchCostInfo: uri => dispatch(doFetchCostInfoForUri(uri)),
|
fetchCostInfo: uri => dispatch(doFetchCostInfoForUri(uri)),
|
||||||
fetchMyClaims: () => dispatch(doFetchClaimListMine()),
|
fetchMyClaims: () => dispatch(doFetchClaimListMine()),
|
||||||
fetchChannelListMine: () => dispatch(doFetchChannelListMine()),
|
fetchChannelListMine: () => dispatch(doFetchChannelListMine()),
|
||||||
|
fetchViewCount: claimId => dispatch(doFetchViewCount(claimId)),
|
||||||
fileGet: (uri, saveFile) => dispatch(doFileGet(uri, saveFile)),
|
fileGet: (uri, saveFile) => dispatch(doFileGet(uri, saveFile)),
|
||||||
notify: data => dispatch(doToast(data)),
|
notify: data => dispatch(doToast(data)),
|
||||||
popDrawerStack: () => dispatch(doPopDrawerStack()),
|
popDrawerStack: () => dispatch(doPopDrawerStack()),
|
||||||
|
|
|
@ -68,6 +68,7 @@ class FilePage extends React.PureComponent {
|
||||||
autoPlayMedia: false,
|
autoPlayMedia: false,
|
||||||
downloadButtonShown: false,
|
downloadButtonShown: false,
|
||||||
downloadPressed: false,
|
downloadPressed: false,
|
||||||
|
didSearchRecommended: false,
|
||||||
fileViewLogged: false,
|
fileViewLogged: false,
|
||||||
fullscreenMode: false,
|
fullscreenMode: false,
|
||||||
fileGetStarted: false,
|
fileGetStarted: false,
|
||||||
|
@ -88,7 +89,7 @@ class FilePage extends React.PureComponent {
|
||||||
uriVars: null,
|
uriVars: null,
|
||||||
stopDownloadConfirmed: false,
|
stopDownloadConfirmed: false,
|
||||||
streamingMode: false,
|
streamingMode: false,
|
||||||
didSearchRecommended: false,
|
viewCountFetched: false,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -115,6 +116,7 @@ class FilePage extends React.PureComponent {
|
||||||
|
|
||||||
this.fetchFileInfo(this.props);
|
this.fetchFileInfo(this.props);
|
||||||
this.fetchCostInfo(this.props);
|
this.fetchCostInfo(this.props);
|
||||||
|
|
||||||
fetchMyClaims();
|
fetchMyClaims();
|
||||||
|
|
||||||
if (NativeModules.Firebase) {
|
if (NativeModules.Firebase) {
|
||||||
|
@ -145,6 +147,7 @@ class FilePage extends React.PureComponent {
|
||||||
claim,
|
claim,
|
||||||
currentRoute,
|
currentRoute,
|
||||||
failedPurchaseUris: prevFailedPurchaseUris,
|
failedPurchaseUris: prevFailedPurchaseUris,
|
||||||
|
fetchViewCount,
|
||||||
purchasedUris: prevPurchasedUris,
|
purchasedUris: prevPurchasedUris,
|
||||||
navigation,
|
navigation,
|
||||||
contentType,
|
contentType,
|
||||||
|
@ -210,6 +213,10 @@ class FilePage extends React.PureComponent {
|
||||||
showWebView: false,
|
showWebView: false,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (claim && !this.state.viewCountFetched) {
|
||||||
|
this.setState({ viewCountFetched: true }, () => fetchViewCount(claim.claim_id));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
componentDidUpdate(prevProps) {
|
componentDidUpdate(prevProps) {
|
||||||
|
@ -726,6 +733,7 @@ class FilePage extends React.PureComponent {
|
||||||
recommendedContent,
|
recommendedContent,
|
||||||
thumbnail,
|
thumbnail,
|
||||||
title,
|
title,
|
||||||
|
viewCount,
|
||||||
} = this.props;
|
} = this.props;
|
||||||
const { uri, autoplay } = navigation.state.params;
|
const { uri, autoplay } = navigation.state.params;
|
||||||
|
|
||||||
|
@ -1013,6 +1021,7 @@ class FilePage extends React.PureComponent {
|
||||||
style={filePageStyle.titleTouch}
|
style={filePageStyle.titleTouch}
|
||||||
onPress={() => this.setState({ showDescription: !this.state.showDescription })}
|
onPress={() => this.setState({ showDescription: !this.state.showDescription })}
|
||||||
>
|
>
|
||||||
|
<View style={filePageStyle.titleArea}>
|
||||||
<View style={filePageStyle.titleRow}>
|
<View style={filePageStyle.titleRow}>
|
||||||
<Text style={filePageStyle.title} selectable>
|
<Text style={filePageStyle.title} selectable>
|
||||||
{title}
|
{title}
|
||||||
|
@ -1022,6 +1031,11 @@ class FilePage extends React.PureComponent {
|
||||||
<Icon name={this.state.showDescription ? 'caret-up' : 'caret-down'} size={24} />
|
<Icon name={this.state.showDescription ? 'caret-up' : 'caret-down'} size={24} />
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
|
<Text style={filePageStyle.viewCount}>
|
||||||
|
{viewCount === 1 && __('%view% view', { view: viewCount })}
|
||||||
|
{viewCount > 1 && __('%view% views', { view: viewCount })}
|
||||||
|
</Text>
|
||||||
|
</View>
|
||||||
</TouchableWithoutFeedback>
|
</TouchableWithoutFeedback>
|
||||||
|
|
||||||
<View style={filePageStyle.largeButtonsRow}>
|
<View style={filePageStyle.largeButtonsRow}>
|
||||||
|
|
|
@ -145,7 +145,7 @@ const channelPageStyle = StyleSheet.create({
|
||||||
position: 'absolute',
|
position: 'absolute',
|
||||||
overflow: 'hidden',
|
overflow: 'hidden',
|
||||||
left: 24,
|
left: 24,
|
||||||
bottom: -40,
|
bottom: -24,
|
||||||
zIndex: 100,
|
zIndex: 100,
|
||||||
alignItems: 'center',
|
alignItems: 'center',
|
||||||
justifyContent: 'center',
|
justifyContent: 'center',
|
||||||
|
@ -176,6 +176,12 @@ const channelPageStyle = StyleSheet.create({
|
||||||
marginLeft: 8,
|
marginLeft: 8,
|
||||||
marginRight: 8,
|
marginRight: 8,
|
||||||
},
|
},
|
||||||
|
followerCount: {
|
||||||
|
fontFamily: 'Inter-UI-Regular',
|
||||||
|
fontSize: 12,
|
||||||
|
color: Colors.White,
|
||||||
|
marginTop: 2,
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
export default channelPageStyle;
|
export default channelPageStyle;
|
||||||
|
|
|
@ -447,6 +447,13 @@ const filePageStyle = StyleSheet.create({
|
||||||
relatedLoading: {
|
relatedLoading: {
|
||||||
marginTop: 16,
|
marginTop: 16,
|
||||||
},
|
},
|
||||||
|
viewCount: {
|
||||||
|
fontFamily: 'Inter-UI-Regular',
|
||||||
|
fontSize: 12,
|
||||||
|
color: Colors.DescriptionGrey,
|
||||||
|
marginLeft: 12,
|
||||||
|
marginRight: 12,
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
export default filePageStyle;
|
export default filePageStyle;
|
||||||
|
|
Loading…
Reference in a new issue