From 535634310b94787968385a3af78daffbcfbc08c5 Mon Sep 17 00:00:00 2001 From: Geido <60598000+geido@users.noreply.github.com> Date: Mon, 21 Feb 2022 16:57:22 +0200 Subject: [PATCH] Fix annotation cache (#18788) --- superset-frontend/src/chart/chartAction.js | 12 ++++++------ .../controls/AnnotationLayerControl/index.jsx | 10 +++++++--- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/superset-frontend/src/chart/chartAction.js b/superset-frontend/src/chart/chartAction.js index 2f371d59dc..8f451444f4 100644 --- a/superset-frontend/src/chart/chartAction.js +++ b/superset-frontend/src/chart/chartAction.js @@ -244,14 +244,14 @@ export async function getChartDataRequest({ ); } -export function runAnnotationQuery( +export function runAnnotationQuery({ annotation, timeout = 60, formData = null, key, isDashboardRequest = false, force = false, -) { +}) { return function (dispatch, getState) { const sliceKey = key || Object.keys(getState().charts)[0]; // make a copy of formData, not modifying original formData @@ -482,16 +482,16 @@ export function exploreJSON( chartDataRequestCaught, dispatch(triggerQuery(false, key)), dispatch(updateQueryFormData(formData, key)), - ...annotationLayers.map(x => + ...annotationLayers.map(annotation => dispatch( - runAnnotationQuery( - x, + runAnnotationQuery({ + annotation, timeout, formData, key, isDashboardRequest, force, - ), + }), ), ), ]); diff --git a/superset-frontend/src/explore/components/controls/AnnotationLayerControl/index.jsx b/superset-frontend/src/explore/components/controls/AnnotationLayerControl/index.jsx index dc0130f039..1fc65365c0 100644 --- a/superset-frontend/src/explore/components/controls/AnnotationLayerControl/index.jsx +++ b/superset-frontend/src/explore/components/controls/AnnotationLayerControl/index.jsx @@ -98,7 +98,11 @@ class AnnotationLayerControl extends React.PureComponent { this.setState({ addedAnnotationIndex: annotations.length - 1 }); } - this.props.refreshAnnotationData(newAnnotation); + this.props.refreshAnnotationData({ + annotation: newAnnotation, + force: true, + }); + this.props.onChange(annotations); } @@ -239,8 +243,8 @@ function mapStateToProps({ charts, explore }) { function mapDispatchToProps(dispatch) { return { - refreshAnnotationData: annotationLayer => - dispatch(runAnnotationQuery(annotationLayer)), + refreshAnnotationData: annotationObj => + dispatch(runAnnotationQuery(annotationObj)), }; }