fix bug on random topic not loading on first page load
This commit is contained in:
parent
7d48fad50a
commit
c9d1495c43
|
@ -18,10 +18,9 @@ class Home extends React.Component {
|
|||
}
|
||||
|
||||
componentWillReceiveProps(nextProps) {
|
||||
//FIXME: this is quite ugly
|
||||
// We are trying to figure out if allTopics is loaded but no request made for random topic yet,
|
||||
// and then we want to load the random topic. But there should be a cleaner way to do this.
|
||||
if (!nextProps.loadingAllTopics && !this.props.randomTopic && (!this.props.loadingRandomTopic || nextProps.loadingRandomTopic)) {
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user