From ad798aa5901c204a9c7c601afa19c293efd4ab0e Mon Sep 17 00:00:00 2001 From: Iris Scholten Date: Thu, 22 Feb 2018 11:54:38 -0800 Subject: [PATCH] prevent execution of queries if preventLoad is true Co-authored-by: Deniz Kusefoglu : --- ui/src/shared/components/AutoRefresh.js | 28 ++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/ui/src/shared/components/AutoRefresh.js b/ui/src/shared/components/AutoRefresh.js index 7bf0e9e160..c1a0abda5d 100644 --- a/ui/src/shared/components/AutoRefresh.js +++ b/ui/src/shared/components/AutoRefresh.js @@ -27,8 +27,10 @@ const AutoRefresh = ComposedComponent => { } componentWillReceiveProps(nextProps) { - const preventLoadDidUpdate = - this.props.preventLoad && !nextProps.preventLoad + const preventLoadDidUpdate = !_.isEqual( + this.props.preventLoad, + nextProps.preventLoad + ) const queriesDidUpdate = this.queryDifference( this.props.queries, @@ -44,7 +46,11 @@ const AutoRefresh = ComposedComponent => { queriesDidUpdate || tempVarsDidUpdate || preventLoadDidUpdate if (shouldRefetch) { - this.executeQueries(nextProps.queries, nextProps.templates) + this.executeQueries( + nextProps.queries, + nextProps.templates, + nextProps.preventLoad + ) } if (this.props.autoRefresh !== nextProps.autoRefresh || shouldRefetch) { @@ -52,7 +58,12 @@ const AutoRefresh = ComposedComponent => { if (nextProps.autoRefresh) { this.intervalID = setInterval( - () => this.executeQueries(nextProps.queries, nextProps.templates), + () => + this.executeQueries( + nextProps.queries, + nextProps.templates, + nextProps.preventLoad + ), nextProps.autoRefresh ) } @@ -68,11 +79,14 @@ const AutoRefresh = ComposedComponent => { ) } - executeQueries = async (queries, templates = []) => { - const {editQueryStatus, grabDataForDownload, preventLoad} = this.props + executeQueries = async ( + queries, + templates = [], + preventLoad = this.props.preventLoad + ) => { + const {editQueryStatus, grabDataForDownload} = this.props const {resolution} = this.state if (preventLoad) { - this.setState({timeSeries: []}) return } if (!queries.length) {