add count for current topic in random topic component

This commit is contained in:
Sanjay Bhangar 2018-12-07 19:43:25 +02:00
parent 69c2181afa
commit 2d755be6b8
3 changed files with 5 additions and 4 deletions

View File

@ -40,7 +40,7 @@ export function getRandomTopicVideos(allTopics, numVideos=4) {
return dispatch => { return dispatch => {
const randomTopic = getRandomTopic(allTopics); const randomTopic = getRandomTopic(allTopics);
dispatch(loadingRandomTopicVideos()); dispatch(loadingRandomTopicVideos());
fetchVideosByTopic(randomTopic, 0, 4) fetchVideosByTopic(randomTopic.name, 0, 4)
.then(videos => { .then(videos => {
dispatch(loadedRandomTopicVideos(randomTopic, videos)); dispatch(loadedRandomTopicVideos(randomTopic, videos));
}); });

View File

@ -21,7 +21,7 @@ class RandomTopic extends React.Component {
See All Topics See All Topics
</Link> </Link>
<Link to="/topics"> <Link to="/topics">
See All videos of {this.props.topicName} () See All videos of {this.props.topicName} ({this.props.topicCount})
</Link> </Link>
</Grid> </Grid>
</section> </section>
@ -33,7 +33,8 @@ class RandomTopic extends React.Component {
RandomTopic.propTypes = { RandomTopic.propTypes = {
topicName: PropTypes.string, topicName: PropTypes.string,
videos: PropTypes.array, videos: PropTypes.array,
loading: PropTypes.bool loading: PropTypes.bool,
topicCount: PropTypes.number
}; };
export default (RandomTopic); export default (RandomTopic);

View File

@ -45,7 +45,7 @@ const mapStateToProps = state => ({
allTopics: state.topics.allTopics, allTopics: state.topics.allTopics,
loadingAllTopics: state.topics.loadingAllTopics, loadingAllTopics: state.topics.loadingAllTopics,
randomTopic: state.topics.randomTopic, randomTopic: state.topics.randomTopic,
randomTopicCount: static.topics.randomTopicCount, randomTopicCount: state.topics.randomTopicCount,
loadingRandomTopic: state.topics.loadingRandomTopic, loadingRandomTopic: state.topics.loadingRandomTopic,
randomTopicVideos: state.topics.randomTopicVideos randomTopicVideos: state.topics.randomTopicVideos
}); });