Skip to content

Commit

Permalink
fix: force visualization fetch to ensure recording for offline (#3196)
Browse files Browse the repository at this point in the history
The visualization request stopped being recorded after recent changes.
The componentDidUpdate method was taking care of the recording, but it
doesn't work as before.
This change ensures the visualization is fetched when the dashboard is
marked for offline so that the request is properly cached.
  • Loading branch information
edoardo authored Jan 28, 2025
1 parent 7aa6f52 commit 42aa33a
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/components/Item/VisualizationItem/Item.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,19 @@ class Item extends Component {
}

async componentDidMount() {
// Avoid refetching the visualization already in the Redux store
// when the same dashboard item is added again.
// This also solves a flashing of all the "duplicated" dashboard items.
!this.props.visualization.id &&
this.props.setVisualization(
await apiFetchVisualization(this.props.item)
)

// force fetch when recording to allow caching of the visualizations request
if (this.props.isRecording) {
apiFetchVisualization(this.props.item)
}

try {
// Avoid refetching the visualization already in the Redux store
// when the same dashboard item is added again.
Expand Down

0 comments on commit 42aa33a

Please sign in to comment.