From 39bf33eb24f15135bac3330b26882468eca7186c Mon Sep 17 00:00:00 2001 From: Travis Eden Date: Tue, 19 Jun 2018 16:59:31 -0400 Subject: [PATCH] set 1hr interval on fetchFeaturedUris --- src/renderer/page/discover/view.jsx | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/src/renderer/page/discover/view.jsx b/src/renderer/page/discover/view.jsx index 123992dc8..084fbebf3 100644 --- a/src/renderer/page/discover/view.jsx +++ b/src/renderer/page/discover/view.jsx @@ -10,10 +10,30 @@ type Props = { }; class DiscoverPage extends React.PureComponent { - 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;