Skip to content

Commit

Permalink
[Discover] Fix false positives when setting chartDisplayChanged, caus…
Browse files Browse the repository at this point in the history
…ing extra fetches
  • Loading branch information
davismcphee committed Dec 3, 2022
1 parent 2a9d568 commit 5ce0423
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,9 @@ export function useDiscoverState({
useEffect(() => {
const unsubscribe = appStateContainer.subscribe(async (nextState) => {
const { hideChart, interval, breakdownField, sort, index } = state;
const chartDisplayChanged = nextState.hideChart !== hideChart;
// Cast to boolean to avoid false positives when comparing
// undefined and false, which would trigger a refetch
const chartDisplayChanged = Boolean(nextState.hideChart) !== Boolean(hideChart);
const chartIntervalChanged = nextState.interval !== interval;
const breakdownFieldChanged = nextState.breakdownField !== breakdownField;
const docTableSortChanged = !isEqual(nextState.sort, sort);
Expand Down

0 comments on commit 5ce0423

Please sign in to comment.