Skip to content

Commit 9dd1347

Browse files
committed
fix: clean up reduandant code flagged in review
1 parent e199212 commit 9dd1347

File tree

2 files changed

+12
-19
lines changed

2 files changed

+12
-19
lines changed

static/app/views/dashboards/dashboard.spec.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -460,9 +460,9 @@ describe('Dashboards > Dashboard', () => {
460460
groups: [],
461461
};
462462

463-
// useChartInterval computes the active interval from PageFiltersStore's
464-
// datetime selection. FiltersBar uses the same hook, so clicking a new
465-
// option updates both the URL and widgetInterval together.
463+
// Mirrors DashboardDetailWithInjectedProps: useChartInterval always provides
464+
// the validated interval for the current period, keeping the FiltersBar
465+
// dropdown and widget requests in sync.
466466
// Accepts an optional dashboard prop so tests can supply a different period.
467467
function DashboardWithIntervalSelector({
468468
dashboard = dashboardWithWidget,

static/app/views/dashboards/detail.tsx

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import isEqual from 'lodash/isEqual';
88
import isEqualWith from 'lodash/isEqualWith';
99
import omit from 'lodash/omit';
1010
import pick from 'lodash/pick';
11-
import {createParser, useQueryState} from 'nuqs';
1211

1312
import {
1413
createDashboard,
@@ -1382,11 +1381,6 @@ const StyledPageHeader = styled('div')`
13821381
}
13831382
`;
13841383

1385-
// 'auto' means "let widgets decide their own interval"; treat it as absent.
1386-
const parseIntervalParam = createParser({
1387-
parse: (value: string): string | null => (value === 'auto' ? null : value),
1388-
serialize: (value: string) => value,
1389-
});
13901384

13911385
interface DashboardDetailWithInjectedPropsProps extends Omit<
13921386
Props,
@@ -1412,16 +1406,15 @@ export default function DashboardDetailWithInjectedProps(
14121406
const params = useParams<RouteParams>();
14131407
const router = useRouter();
14141408
const [chartInterval] = useChartInterval();
1415-
const [intervalParam] = useQueryState('interval', parseIntervalParam);
1416-
1417-
// Validate the URL interval against the current page filter period so widgets
1418-
// never make requests with an interval that is too granular (e.g. 1m over 30d).
1419-
// intervalParam is null when absent or 'auto' (both mean "let widgets decide").
1420-
const validatedWidgetInterval =
1421-
organization.features.includes('dashboards-interval-selection') &&
1422-
intervalParam !== null
1423-
? chartInterval
1424-
: undefined;
1409+
1410+
// Always use the validated chart interval so the UI dropdown and widget
1411+
// requests stay in sync. chartInterval is validated against the current page
1412+
// filter period (e.g. won't return 1m for a 30d range) and always has a value.
1413+
const validatedWidgetInterval = organization.features.includes(
1414+
'dashboards-interval-selection'
1415+
)
1416+
? chartInterval
1417+
: undefined;
14251418

14261419
return (
14271420
<DashboardDetail

0 commit comments

Comments
 (0)