really fix issues with random topic on first load

This commit is contained in:
Sanjay Bhangar 2018-12-07 19:33:42 +02:00
parent c9d1495c43
commit f667e9ea8f

View File

@ -18,10 +18,11 @@ class Home extends React.Component {
}
componentWillReceiveProps(nextProps) {
console.log('nextProps', nextProps);
// This is slightly awkward - we need to check that we have all topics,
// But don't have a random topic yet (or at not already loading a random topic)
if (this.props.allTopics && !(this.props.loadingRandomTopic || nextProps.loadingRandomTopic) && !this.props.randomTopic) {
this.props.getRandomTopicVideos(this.props.allTopics);
if ((this.props.allTopics || nextProps.allTopics) && !this.props.loadingRandomTopic && !nextProps.loadingRandomTopic && !this.props.randomTopic) {
this.props.getRandomTopicVideos(nextProps.allTopics);
}
}