set 1hr interval on fetchFeaturedUris

This commit is contained in:
Travis Eden 2018-06-19 16:59:31 -04:00
parent 941672bd81
commit 39bf33eb24

View file

@ -10,10 +10,30 @@ type Props = {
};
class DiscoverPage extends React.PureComponent<Props> {
componentWillMount() {
this.props.fetchFeaturedUris();
constructor() {
super();
this.continousFetch = undefined;
}
componentWillMount() {
const { fetchFeaturedUris } = this.props;
fetchFeaturedUris();
this.continousFetch = setInterval(fetchFeaturedUris, 1000 * 60 * 60);
}
componentWillUnmount() {
this.clearContinuousFetch();
}
clearContinuousFetch() {
if (this.continousFetch) {
clearInterval(this.continousFetch);
this.continousFetch = null;
}
}
continousFetch: ?number;
render() {
const { featuredUris, fetchingFeaturedUris } = this.props;
const hasContent = typeof featuredUris === 'object' && Object.keys(featuredUris).length;