set 1hr interval on fetchFeaturedUris
This commit is contained in:
parent
941672bd81
commit
39bf33eb24
1 changed files with 22 additions and 2 deletions
|
@ -10,10 +10,30 @@ type Props = {
|
||||||
};
|
};
|
||||||
|
|
||||||
class DiscoverPage extends React.PureComponent<Props> {
|
class DiscoverPage extends React.PureComponent<Props> {
|
||||||
componentWillMount() {
|
constructor() {
|
||||||
this.props.fetchFeaturedUris();
|
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() {
|
render() {
|
||||||
const { featuredUris, fetchingFeaturedUris } = this.props;
|
const { featuredUris, fetchingFeaturedUris } = this.props;
|
||||||
const hasContent = typeof featuredUris === 'object' && Object.keys(featuredUris).length;
|
const hasContent = typeof featuredUris === 'object' && Object.keys(featuredUris).length;
|
||||||
|
|
Loading…
Reference in a new issue