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) {
|
componentWillReceiveProps(nextProps) {
|
||||||
//FIXME: this is quite ugly
|
// This is slightly awkward - we need to check that we have all topics,
|
||||||
// We are trying to figure out if allTopics is loaded but no request made for random topic yet,
|
// But don't have a random topic yet (or at not already loading a random topic)
|
||||||
// and then we want to load the random topic. But there should be a cleaner way to do this.
|
if (this.props.allTopics && !(this.props.loadingRandomTopic || nextProps.loadingRandomTopic) && !this.props.randomTopic) {
|
||||||
if (!nextProps.loadingAllTopics && !this.props.randomTopic && (!this.props.loadingRandomTopic || nextProps.loadingRandomTopic)) {
|
|
||||||
this.props.getRandomTopicVideos(this.props.allTopics);
|
this.props.getRandomTopicVideos(this.props.allTopics);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user