From 7c4bb8a13b513200c61045488a2d64452f4bf350 Mon Sep 17 00:00:00 2001 From: Edoardo Sabadelli Date: Fri, 31 May 2024 15:49:33 +0200 Subject: [PATCH] fix: fetch visualization always when caching A previous fix for an item flashing issue caused the offline cache to lack the request for the visualizations. The fix looks at the recording state and triggers a fetch that can be recorded. (cherry picked from commit c1201fa46dfbb8ee524dbc1087bad9f45bc22c65) --- src/components/Item/VisualizationItem/Item.js | 10 ++++++++++ src/pages/view/ItemGrid.js | 1 + 2 files changed, 11 insertions(+) diff --git a/src/components/Item/VisualizationItem/Item.js b/src/components/Item/VisualizationItem/Item.js index 3aa9f6fd9..8685711b0 100644 --- a/src/components/Item/VisualizationItem/Item.js +++ b/src/components/Item/VisualizationItem/Item.js @@ -104,6 +104,15 @@ class Item extends Component { this.setState({ configLoaded: true }) } + componentDidUpdate(prevProps) { + if ( + this.props.isRecording && + this.props.isRecording !== prevProps.isRecording + ) { + apiFetchVisualization(this.props.item) + } + } + isFullscreenSupported = () => { const el = getGridItemElement(this.props.item.id) return !!(el?.requestFullscreen || el?.webkitRequestFullscreen) @@ -280,6 +289,7 @@ Item.propTypes = { dashboardMode: PropTypes.string, gridWidth: PropTypes.number, isEditing: PropTypes.bool, + isRecording: PropTypes.bool, item: PropTypes.object, itemFilters: PropTypes.object, setActiveType: PropTypes.func, diff --git a/src/pages/view/ItemGrid.js b/src/pages/view/ItemGrid.js index 017e765f5..9beb65bd3 100644 --- a/src/pages/view/ItemGrid.js +++ b/src/pages/view/ItemGrid.js @@ -109,6 +109,7 @@ const ResponsiveItemGrid = ({ dashboardId, dashboardItems }) => { item={item} gridWidth={gridWidth} dashboardMode={VIEW} + isRecording={forceLoad} onToggleItemExpanded={onToggleItemExpanded} />