Skip to content

Commit

Permalink
fix: avoid extra analytics request when loading a new AO
Browse files Browse the repository at this point in the history
  • Loading branch information
edoardo committed Jan 29, 2024
1 parent 4709e03 commit 3a8c98e
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions src/components/Visualization/Visualization.js
Original file line number Diff line number Diff line change
Expand Up @@ -260,18 +260,29 @@ export const Visualization = ({
}
}

const { fetching, error, data } = useAnalyticsData({
const analyticsArgs = {
filters,
visualization,
isVisualizationLoading,
displayProperty,
onResponsesReceived,
pageSize,
// Set first page directly for new visualization to avoid extra request with current page
page: visualization !== visualizationRef.current ? FIRST_PAGE : page,
page,
sortField,
sortDirection,
})
}

// Set first page and sorting directly for new visualization to avoid extra analytics requests
if (visualization !== visualizationRef.current) {
const { sortField, sortDirection } = getSorting(visualization)

analyticsArgs.sortField = sortField
analyticsArgs.sortDirection = sortDirection

analyticsArgs.page = FIRST_PAGE
}

const { fetching, error, data } = useAnalyticsData(analyticsArgs)

const fetchIndicatorTop = useMemo(() => {
if (
Expand Down

0 comments on commit 3a8c98e

Please sign in to comment.